Spaces:
Runtime error
Runtime error
init
Browse files- app.py +15 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
+
from sentence_transformers import SentenceTransformer
|
5 |
+
|
6 |
+
model = SentenceTransformer('clip-ViT-B-32')
|
7 |
+
|
8 |
+
|
9 |
+
def image_to_embedding(img: np.ndarray):
|
10 |
+
embedding = model.encode(sentences=[Image.fromarray(img)], batch_size=128)
|
11 |
+
return embedding
|
12 |
+
|
13 |
+
|
14 |
+
iface = gr.Interface(fn=image_to_embedding, inputs="image", outputs="textbox", cache_examples=True)
|
15 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio~=3.41.2
|
2 |
+
sentence-transformers
|
3 |
+
numpy~=1.25.2
|
4 |
+
Pillow~=10.0.0
|