Docfile commited on
Commit
cddd4e0
·
verified ·
1 Parent(s): 59d059f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -1,14 +1,5 @@
1
  import gradio as gr
2
  import google.generativeai as genai
3
- from IPython.display import Markdown
4
- import textwrap
5
-
6
- def to_markdown(text):
7
- if text is not None:
8
- text = text.replace('•', ' *')
9
- return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
10
- else:
11
- return Markdown("No response received.")
12
 
13
  token = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko"
14
  genai.configure(api_key=token)
@@ -18,10 +9,10 @@ model = genai.GenerativeModel(model_name="gemini-pro-vision")
18
 
19
  # Fonction pour générer le contenu
20
  def generate_content(image):
21
- response = model.generate_content(["Write a short, engaging blog post based on this picture. It should include a description of the meal in the photo and talk about my journey meal prepping.", image], stream=True)
22
  print(response.text)
23
- markdown_response = to_markdown(response.resolve())
24
- return markdown_response
25
 
26
  # Interface Gradio
27
  iface = gr.Interface(fn=generate_content, inputs=gr.Image(type='pil'), outputs="text")
 
1
  import gradio as gr
2
  import google.generativeai as genai
 
 
 
 
 
 
 
 
 
3
 
4
  token = "AIzaSyDYhyRoOWBJWOb4bqY5wmFLrBo4HTwQDko"
5
  genai.configure(api_key=token)
 
9
 
10
  # Fonction pour générer le contenu
11
  def generate_content(image):
12
+ response = model.generate_content(["Write a short, engaging blog post based on this picture. It should include a description of the meal in the photo and talk about my journey meal prepping.", image])
13
  print(response.text)
14
+
15
+ return response.resolve()
16
 
17
  # Interface Gradio
18
  iface = gr.Interface(fn=generate_content, inputs=gr.Image(type='pil'), outputs="text")