Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -92,43 +92,12 @@ def ImageChat(image, prompt="Analyze"):
|
|
92 |
except ValueError as e:
|
93 |
return f"Error in generating response: {e}"
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
app = gr.Blocks()
|
106 |
-
|
107 |
-
with app:
|
108 |
-
with gr.Column():
|
109 |
-
image_input = gr.Image(type="pil", label="")
|
110 |
-
prompt_input = gr.Textbox(label="Your Prompt", value="Analyze")
|
111 |
-
output_field = gr.Markdown(label="Response")
|
112 |
-
|
113 |
-
with gr.Row():
|
114 |
-
copy_button = gr.Button("Copy")
|
115 |
-
export_button = gr.Button("Export")
|
116 |
-
|
117 |
-
def process_image(image, prompt):
|
118 |
-
response = ImageChat(image, prompt)
|
119 |
-
return response
|
120 |
-
|
121 |
-
def copy_callback(output_text):
|
122 |
-
import pyperclip
|
123 |
-
pyperclip.copy(output_text)
|
124 |
-
return "Copied to clipboard!"
|
125 |
-
|
126 |
-
def export_callback(output_text):
|
127 |
-
with open("output.txt", "w") as file:
|
128 |
-
file.write(output_text)
|
129 |
-
return "Output exported to output.txt"
|
130 |
-
|
131 |
-
copy_button.click(fn=copy_callback, inputs=[output_field], outputs=[])
|
132 |
-
export_button.click(fn=export_callback, inputs=[output_field], outputs=[])
|
133 |
-
|
134 |
-
app.launch()
|
|
|
92 |
except ValueError as e:
|
93 |
return f"Error in generating response: {e}"
|
94 |
|
95 |
+
app = gr.Interface(
|
96 |
+
fn=ImageChat,
|
97 |
+
inputs=[gr.Image(label=""), gr.Textbox(label="Your Prompt", value="Analyze")],
|
98 |
+
outputs=gr.Textbox(label="Response"),
|
99 |
+
title = "",
|
100 |
+
theme=gr.themes.Soft()
|
101 |
+
)
|
102 |
+
|
103 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|