Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,11 @@ import gradio as gr
|
|
| 3 |
from transformers import CLIPProcessor, CLIPModel
|
| 4 |
import spaces
|
| 5 |
|
| 6 |
-
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch16")
|
| 7 |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch16")
|
| 8 |
|
| 9 |
-
@spaces.GPU
|
| 10 |
def calculate_score(image, text):
|
| 11 |
-
model.to("cuda") # Move model to CUDA inside the GPU-decorated function
|
| 12 |
-
|
| 13 |
labels = text.split(";")
|
| 14 |
labels = [l.strip() for l in labels]
|
| 15 |
labels = list(filter(None, labels))
|
|
|
|
| 3 |
from transformers import CLIPProcessor, CLIPModel
|
| 4 |
import spaces
|
| 5 |
|
| 6 |
+
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch16").to("cuda")
|
| 7 |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch16")
|
| 8 |
|
| 9 |
+
@spaces.GPU(duration=120)
|
| 10 |
def calculate_score(image, text):
|
|
|
|
|
|
|
| 11 |
labels = text.split(";")
|
| 12 |
labels = [l.strip() for l in labels]
|
| 13 |
labels = list(filter(None, labels))
|