Ifeanyi commited on
Commit
8d03104
·
verified ·
1 Parent(s): 1e1c343

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -34
app.py CHANGED
@@ -1,35 +1,15 @@
1
- import google.generativeai as genai
2
  import gradio as gr
3
- import numpy as np
4
- import PIL.Image
5
-
6
- genai.configure(api_key="AIzaSyA7tPavobVN5_3-BJ0qhFT5HVjO4V19QWk")
7
-
8
- def ImageChat(image):
9
-
10
- # load model
11
- model = genai.GenerativeModel("gemini-1.5-flash")
12
-
13
- # check image file and convert to a Numpy array
14
- if isinstance(image, np.ndarray):
15
-
16
- img = PIL.Image.fromarray(image)
17
- else:
18
- img = PIL.Image.open(image)
19
-
20
- response = model.generate_content(["write a short story about the image", img])
21
-
22
- return response.text
23
-
24
-
25
- app = gr.Interface(ImageChat,
26
- inputs = gr.Image(label = "Image"),
27
- outputs = gr.Text(label = "Story"),
28
- examples = ["rubiks cube.jpg","giraffe.jpg","street.jpg"],
29
- title = "Image-To-Story",
30
- theme = "patrickosornio/my_theme1")
31
-
32
-
33
- app.launch()
34
-
35
-
 
 
1
  import gradio as gr
2
+ import groq_gradio
3
+ import os
4
+
5
+ os.environ["GROQ_API_KEY"] = "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"
6
+ gr.load(
7
+ name = "llama-3.2-3b-preview",
8
+ src = groq_gradio.registry,
9
+ title = "Groq-Gradio Chat",
10
+ theme = "ParityError/LimeFace",
11
+ examples = ["Tell me a short story about a puppy",
12
+ "Write a 14 line poem about travelling in Shakespeare style",
13
+ "What are the wonders of the world?",
14
+ "List the countries in Africa and their capitals"]
15
+ ).launch()