Upload app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ import requests
|
|
| 10 |
from io import BytesIO
|
| 11 |
|
| 12 |
# Use CPU and smaller memory footprint
|
| 13 |
-
device = "cpu"
|
| 14 |
model = None
|
| 15 |
processor = None
|
| 16 |
|
|
@@ -51,13 +50,14 @@ def get_embedding_from_url(image_url: str):
|
|
| 51 |
except Exception as e:
|
| 52 |
return {"success": False, "error": str(e)}
|
| 53 |
|
| 54 |
-
# Gradio interface
|
| 55 |
demo = gr.Interface(
|
| 56 |
fn=get_embedding_from_url,
|
| 57 |
inputs=gr.Textbox(label="Image URL", placeholder="https://example.com/image.jpg"),
|
| 58 |
outputs=gr.JSON(label="Result"),
|
| 59 |
title="CLIP Embedding API",
|
| 60 |
-
description="Get 512-dim CLIP embeddings for images"
|
|
|
|
| 61 |
)
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|
|
|
|
| 10 |
from io import BytesIO
|
| 11 |
|
| 12 |
# Use CPU and smaller memory footprint
|
|
|
|
| 13 |
model = None
|
| 14 |
processor = None
|
| 15 |
|
|
|
|
| 50 |
except Exception as e:
|
| 51 |
return {"success": False, "error": str(e)}
|
| 52 |
|
| 53 |
+
# Gradio interface with API enabled
|
| 54 |
demo = gr.Interface(
|
| 55 |
fn=get_embedding_from_url,
|
| 56 |
inputs=gr.Textbox(label="Image URL", placeholder="https://example.com/image.jpg"),
|
| 57 |
outputs=gr.JSON(label="Result"),
|
| 58 |
title="CLIP Embedding API",
|
| 59 |
+
description="Get 512-dim CLIP embeddings for images",
|
| 60 |
+
api_name="predict"
|
| 61 |
)
|
| 62 |
|
| 63 |
if __name__ == "__main__":
|