vitvit
commited on
Commit
•
a86cf7a
0
Parent(s):
initial commit
Browse files- .gitattributes +35 -0
- README.md +12 -0
- app.py +46 -0
- requirements.txt +0 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: New Space
|
3 |
+
emoji: 🐢
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: indigo
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.0.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This is a Gradio app for similarity image search.
|
2 |
+
# The app takes a text input and returns the top_k images based on similarity.
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
import numpy as np
|
6 |
+
import pandas as pd
|
7 |
+
|
8 |
+
# Dummy function to simulate image search based on text input
|
9 |
+
def similarity_image_search(text, top_k):
|
10 |
+
# Simulate a database of images with their similarity scores
|
11 |
+
images = [
|
12 |
+
("image1.jpg", 0.95),
|
13 |
+
("image2.jpg", 0.85),
|
14 |
+
("image3.jpg", 0.75),
|
15 |
+
("image4.jpg", 0.65),
|
16 |
+
("image5.jpg", 0.55),
|
17 |
+
("image6.jpg", 0.45),
|
18 |
+
("image7.jpg", 0.35),
|
19 |
+
("image8.jpg", 0.25),
|
20 |
+
("image9.jpg", 0.15),
|
21 |
+
("image10.jpg", 0.05),
|
22 |
+
]
|
23 |
+
|
24 |
+
# Sort images by similarity score in descending order
|
25 |
+
images.sort(key=lambda x: x[1], reverse=True)
|
26 |
+
|
27 |
+
# Return the top_k images
|
28 |
+
return [img[0] for img in images[:top_k]]
|
29 |
+
|
30 |
+
# Create a Gradio interface
|
31 |
+
with gr.Blocks() as demo:
|
32 |
+
# Text input for the search query
|
33 |
+
text_input = gr.Textbox(label="Search Query")
|
34 |
+
|
35 |
+
# Slider to select the number of top images to display
|
36 |
+
top_k_slider = gr.Slider(1, 10, value=5, label="Number of Top Images")
|
37 |
+
|
38 |
+
# Gallery to display the top_k images
|
39 |
+
image_gallery = gr.Gallery(label="Top Images", columns=3)
|
40 |
+
|
41 |
+
# Define the event listener for the text input
|
42 |
+
text_input.submit(similarity_image_search, inputs=[text_input, top_k_slider], outputs=image_gallery)
|
43 |
+
|
44 |
+
# Launch the Gradio app
|
45 |
+
if __name__ == "__main__":
|
46 |
+
demo.launch(show_error=True)
|
requirements.txt
ADDED
File without changes
|