Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ 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="AIzaSyAj-b3sO_wUguMdpXWScxKzMHxb8C5cels")
|
7 |
|
@@ -52,20 +53,34 @@ def ImageChat(image):
|
|
52 |
formatted_response = response.text
|
53 |
for title in ["Trend Analysis", "Price Action", "Entry Point", "Exit Point", "Hold Conditions", "Risk Management", "Timeframe", "Profit Potential"]:
|
54 |
formatted_response = formatted_response.replace(title, f"**{title.upper()}**")
|
55 |
-
formatted_response = formatted_response.replace('\n', '\n\n')
|
56 |
formatted_response = re.sub(r"(\d+\.?\d*)", r"**\1**", formatted_response)
|
|
|
57 |
return formatted_response
|
58 |
except ValueError as e:
|
59 |
return f"Error in generating response: {e}"
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
app = gr.Interface(
|
62 |
-
fn=
|
63 |
-
inputs=
|
64 |
-
outputs=
|
65 |
title="Image Chat",
|
66 |
-
theme=gr.themes.Soft()
|
67 |
-
live=False
|
68 |
)
|
69 |
|
70 |
-
#
|
71 |
-
app.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
import PIL.Image
|
5 |
+
import re
|
6 |
|
7 |
genai.configure(api_key="AIzaSyAj-b3sO_wUguMdpXWScxKzMHxb8C5cels")
|
8 |
|
|
|
53 |
formatted_response = response.text
|
54 |
for title in ["Trend Analysis", "Price Action", "Entry Point", "Exit Point", "Hold Conditions", "Risk Management", "Timeframe", "Profit Potential"]:
|
55 |
formatted_response = formatted_response.replace(title, f"**{title.upper()}**")
|
|
|
56 |
formatted_response = re.sub(r"(\d+\.?\d*)", r"**\1**", formatted_response)
|
57 |
+
formatted_response = formatted_response.replace('\n', '\n\n')
|
58 |
return formatted_response
|
59 |
except ValueError as e:
|
60 |
return f"Error in generating response: {e}"
|
61 |
|
62 |
+
# Define the Gradio interface
|
63 |
+
image_input = gr.Image(label="Image")
|
64 |
+
analyze_button = gr.Button("Analyze", elem_id="analyze_button")
|
65 |
+
response_output = gr.Text(label="Response")
|
66 |
+
|
67 |
+
def analyze_image(image):
|
68 |
+
return ImageChat(image)
|
69 |
+
|
70 |
app = gr.Interface(
|
71 |
+
fn=analyze_image,
|
72 |
+
inputs=image_input,
|
73 |
+
outputs=response_output,
|
74 |
title="Image Chat",
|
75 |
+
theme=gr.themes.Soft()
|
|
|
76 |
)
|
77 |
|
78 |
+
# Style the analyze button
|
79 |
+
app.css = """
|
80 |
+
#analyze_button {
|
81 |
+
background-color: #26de81;
|
82 |
+
color: #ffffff;
|
83 |
+
}
|
84 |
+
"""
|
85 |
+
|
86 |
+
app.launch()
|