davanstrien HF staff commited on
Commit
eb84e41
·
1 Parent(s): f782fff

chore: Refactor app.py for improved code organization and readability

Browse files
Files changed (1) hide show
  1. app.py +32 -22
app.py CHANGED
@@ -138,28 +138,38 @@ h1 {
138
  }
139
  """
140
 
141
- demo = gr.Interface(
142
- fn=search_by_text_and_return_images,
143
- inputs=[
144
- gr.Textbox(
145
- label="Enter your cosmic query",
146
- placeholder="e.g., alien abduction, crop circles",
147
- ),
148
- gr.Slider(
149
- minimum=1,
150
- maximum=10,
151
- step=1,
152
- label="Number of classified documents",
153
- value=5,
154
- ),
155
- ],
156
- outputs=gr.Gallery(label="Declassified UFO Sightings", elem_id="gallery"),
157
- title="<h1>🛸 Top Secret UFO Document Search 🛸</h1>",
158
- description="<marquee direction='left' scrollamount='5' class='yellow-text'>Uncover the truth that's out there! The government doesn't want you to know!</marquee>",
159
- css=css,
160
- allow_flagging="never",
161
- theme=geocities90s,
162
- )
 
 
 
 
 
 
 
 
 
163
 
 
164
  if __name__ == "__main__":
165
  demo.launch()
 
138
  }
139
  """
140
 
141
+ # Replace the demo definition with this Blocks implementation
142
+ with gr.Blocks(css=css, theme=geocities90s) as demo:
143
+ gr.HTML("<h1>🛸 Top Secret UFO Document Search 🛸</h1>")
144
+ gr.HTML(
145
+ "<marquee direction='left' scrollamount='5' class='yellow-text'>Uncover the truth that's out there! The government doesn't want you to know!</marquee>"
146
+ )
147
+
148
+ with gr.Row():
149
+ with gr.Column(scale=3):
150
+ query_input = gr.Textbox(
151
+ label="Enter your cosmic query",
152
+ placeholder="e.g., alien abduction, crop circles",
153
+ )
154
+ with gr.Column(scale=1):
155
+ num_results = gr.Slider(
156
+ minimum=1,
157
+ maximum=10,
158
+ step=1,
159
+ label="Number of classified documents",
160
+ value=5,
161
+ )
162
+
163
+ search_button = gr.Button("Declassify Documents")
164
+
165
+ gallery_output = gr.Gallery(label="Declassified UFO Sightings", elem_id="gallery")
166
+
167
+ search_button.click(
168
+ fn=search_by_text_and_return_images,
169
+ inputs=[query_input, num_results],
170
+ outputs=gallery_output,
171
+ )
172
 
173
+ # Keep the main block
174
  if __name__ == "__main__":
175
  demo.launch()