Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -246,6 +246,8 @@ def record_participant(email, company, description, images):
|
|
246 |
return pdf_file
|
247 |
|
248 |
def create_pdf(images, description, email, company):
|
|
|
|
|
249 |
filename = f"image_search_results_{email}.pdf"
|
250 |
c = canvas.Canvas(filename, pagesize=letter)
|
251 |
width, height = letter
|
@@ -280,6 +282,7 @@ def create_pdf(images, description, email, company):
|
|
280 |
y_position -= 15 # Adjust for line spacing
|
281 |
|
282 |
for image in images:
|
|
|
283 |
y_position -= 300 # Adjust this based on your image sizes
|
284 |
if y_position <= 150:
|
285 |
c.showPage()
|
@@ -367,6 +370,48 @@ def start_image_search(image, text):
|
|
367 |
|
368 |
with gr.Blocks() as demo:
|
369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
with gr.Tab("Chat RAG Demo"):
|
371 |
with gr.Tab("Demo"):
|
372 |
gr.ChatInterface(get_movies, examples=["What movies are scary?", "Find me a comedy", "Movies for kids"], title="Movies Atlas Vector Search",description="This small chat uses a similarity search to find relevant movies, it uses MongoDB Atlas Vector Search read more here: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-tutorial",submit_btn="Search").queue()
|
@@ -408,48 +453,7 @@ with gr.Blocks() as demo:
|
|
408 |
with gr.Tab("Code"):
|
409 |
gr.Code(label="Code", language="python", value=fetch_url_data('https://huggingface.co/spaces/MongoDB/whatscooking-advisor/raw/main/app.py'))
|
410 |
|
411 |
-
with gr.Tab("Celeb Matcher Demo"):
|
412 |
-
with gr.Tab("Demo"):
|
413 |
-
gr.Markdown("""
|
414 |
-
# MongoDB's Vector Celeb Image Matcher
|
415 |
-
|
416 |
-
Upload an image and find the most similar celeb image from the database, along with an AI-generated description.
|
417 |
-
|
418 |
-
💪 Make a great pose to impact the search! 🤯
|
419 |
-
""")
|
420 |
-
with gr.Row():
|
421 |
-
with gr.Column():
|
422 |
-
image_input = gr.Image(type="pil", label="Upload an image")
|
423 |
-
text_input = gr.Textbox(label="Enter an adjustment to the image")
|
424 |
-
search_button = gr.Button("Search")
|
425 |
-
|
426 |
-
|
427 |
-
with gr.Column():
|
428 |
-
output_gallery = gr.Gallery(label="Located images", show_label=False, elem_id="gallery",
|
429 |
-
columns=[3], rows=[1], object_fit="contain", height="auto")
|
430 |
-
output_description = gr.Textbox(label="AI Based vision description")
|
431 |
-
gr.Markdown("""
|
432 |
-
|
433 |
-
""")
|
434 |
-
with gr.Row():
|
435 |
-
email_input = gr.Textbox(label="Enter your email")
|
436 |
-
company_input = gr.Textbox(label="Enter your company name")
|
437 |
-
record_button = gr.Button("Record & Download PDF")
|
438 |
-
|
439 |
-
search_button.click(
|
440 |
-
fn=start_image_search,
|
441 |
-
inputs=[image_input, text_input],
|
442 |
-
outputs=[output_gallery, output_description]
|
443 |
-
)
|
444 |
|
445 |
-
record_button.click(
|
446 |
-
fn=record_participant,
|
447 |
-
inputs=[email_input, company_input, output_description, output_gallery],
|
448 |
-
outputs=gr.File(label="Download Search Results as PDF")
|
449 |
-
)
|
450 |
-
with gr.Tab("Code"):
|
451 |
-
gr.Code(label="Code", language="python", value=fetch_url_data('https://huggingface.co/spaces/MongoDB/aws-bedrock-celeb-matcher/raw/main/app.py'))
|
452 |
-
|
453 |
|
454 |
if __name__ == "__main__":
|
455 |
demo.launch()
|
|
|
246 |
return pdf_file
|
247 |
|
248 |
def create_pdf(images, description, email, company):
|
249 |
+
print(images)
|
250 |
+
|
251 |
filename = f"image_search_results_{email}.pdf"
|
252 |
c = canvas.Canvas(filename, pagesize=letter)
|
253 |
width, height = letter
|
|
|
282 |
y_position -= 15 # Adjust for line spacing
|
283 |
|
284 |
for image in images:
|
285 |
+
print(image)
|
286 |
y_position -= 300 # Adjust this based on your image sizes
|
287 |
if y_position <= 150:
|
288 |
c.showPage()
|
|
|
370 |
|
371 |
with gr.Blocks() as demo:
|
372 |
|
373 |
+
with gr.Tab("Celeb Matcher Demo"):
|
374 |
+
with gr.Tab("Demo"):
|
375 |
+
gr.Markdown("""
|
376 |
+
# MongoDB's Vector Celeb Image Matcher
|
377 |
+
|
378 |
+
Upload an image and find the most similar celeb image from the database, along with an AI-generated description.
|
379 |
+
|
380 |
+
💪 Make a great pose to impact the search! 🤯
|
381 |
+
""")
|
382 |
+
with gr.Row():
|
383 |
+
with gr.Column():
|
384 |
+
image_input = gr.Image(type="pil", label="Upload an image")
|
385 |
+
text_input = gr.Textbox(label="Enter an adjustment to the image")
|
386 |
+
search_button = gr.Button("Search")
|
387 |
+
|
388 |
+
|
389 |
+
with gr.Column():
|
390 |
+
output_gallery = gr.Gallery(label="Located images", show_label=False, elem_id="gallery",
|
391 |
+
columns=[3], rows=[1], object_fit="contain", height="auto")
|
392 |
+
output_description = gr.Textbox(label="AI Based vision description")
|
393 |
+
gr.Markdown("""
|
394 |
+
|
395 |
+
""")
|
396 |
+
with gr.Row():
|
397 |
+
email_input = gr.Textbox(label="Enter your email")
|
398 |
+
company_input = gr.Textbox(label="Enter your company name")
|
399 |
+
record_button = gr.Button("Record & Download PDF")
|
400 |
+
|
401 |
+
search_button.click(
|
402 |
+
fn=start_image_search,
|
403 |
+
inputs=[image_input, text_input],
|
404 |
+
outputs=[output_gallery, output_description]
|
405 |
+
)
|
406 |
+
|
407 |
+
record_button.click(
|
408 |
+
fn=record_participant,
|
409 |
+
inputs=[email_input, company_input, output_description, output_gallery],
|
410 |
+
outputs=gr.File(label="Download Search Results as PDF")
|
411 |
+
)
|
412 |
+
with gr.Tab("Code"):
|
413 |
+
gr.Code(label="Code", language="python", value=fetch_url_data('https://huggingface.co/spaces/MongoDB/aws-bedrock-celeb-matcher/raw/main/app.py'))
|
414 |
+
|
415 |
with gr.Tab("Chat RAG Demo"):
|
416 |
with gr.Tab("Demo"):
|
417 |
gr.ChatInterface(get_movies, examples=["What movies are scary?", "Find me a comedy", "Movies for kids"], title="Movies Atlas Vector Search",description="This small chat uses a similarity search to find relevant movies, it uses MongoDB Atlas Vector Search read more here: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-tutorial",submit_btn="Search").queue()
|
|
|
453 |
with gr.Tab("Code"):
|
454 |
gr.Code(label="Code", language="python", value=fetch_url_data('https://huggingface.co/spaces/MongoDB/whatscooking-advisor/raw/main/app.py'))
|
455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
|
458 |
if __name__ == "__main__":
|
459 |
demo.launch()
|