sohoso commited on
Commit
101cd39
·
verified ·
1 Parent(s): d4fc0d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -40
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
- def copy_to_clipboard(output_text):
96
- import pyperclip
97
- pyperclip.copy(output_text)
98
- return "Copied to clipboard!"
99
-
100
- def export_to_file(output_text):
101
- with open("output.txt", "w") as file:
102
- file.write(output_text)
103
- return "Output exported to output.txt"
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()