sohoso commited on
Commit
d8e8571
·
verified ·
1 Parent(s): 6a695f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -29
app.py CHANGED
@@ -102,32 +102,17 @@ def export_to_file(output_text):
102
  file.write(output_text)
103
  return "Output exported to output.txt"
104
 
105
- app = gr.Blocks()
106
-
107
- with app:
108
- image_input = gr.Image(type="pil", label="")
109
- prompt_input = gr.Textbox(label="Your Prompt", value="Analyze")
110
- output_field = gr.Markdown(label="Response")
111
-
112
- with gr.Row():
113
- copy_button = gr.Button("Copy")
114
- export_button = gr.Button("Export")
115
-
116
- def process_image(image, prompt):
117
- response = ImageChat(image, prompt)
118
- return response
119
-
120
- copy_button.click(fn=copy_to_clipboard, inputs=[output_field], outputs=[])
121
- export_button.click(fn=export_to_file, inputs=[output_field], outputs=[])
122
-
123
- interface = gr.Interface(
124
- fn=process_image,
125
- inputs=[image_input, prompt_input],
126
- outputs=[output_field],
127
- title="",
128
- theme=gr.themes.Soft()
129
- )
130
-
131
- interface.launch()
132
-
133
- app.launch()
 
102
  file.write(output_text)
103
  return "Output exported to output.txt"
104
 
105
+ def process_image(image, prompt):
106
+ response = ImageChat(image, prompt)
107
+ return response
108
+
109
+ app = gr.Interface(
110
+ fn=process_image,
111
+ inputs=[gr.Image(type="pil", label=""), gr.Textbox(label="Your Prompt", value="Analyze")],
112
+ outputs=[gr.HTML(label="Response")],
113
+ title="",
114
+ theme=gr.themes.Soft()
115
+ )
116
+
117
+ # Add custom JS for copy and export buttons
118
+ app.launch(share=True, inline=True, server_name="0.0.0.0", server_port=7860)