Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
@@ -19,13 +19,13 @@ model.to(device)
|
|
19 |
|
20 |
|
21 |
def generate_image(text):
|
22 |
-
return "./assets/ICA-Logo.png"
|
23 |
|
24 |
# Interface do Gradio
|
25 |
iface = gr.Interface(
|
26 |
fn=generate_image,
|
27 |
inputs="text",
|
28 |
-
outputs="
|
29 |
live=True,
|
30 |
capture_session=True,
|
31 |
title="Texto para Imagem",
|
|
|
19 |
|
20 |
|
21 |
def generate_image(text):
|
22 |
+
return Image.open("./assets/ICA-Logo.png").convert("RGB")
|
23 |
|
24 |
# Interface do Gradio
|
25 |
iface = gr.Interface(
|
26 |
fn=generate_image,
|
27 |
inputs="text",
|
28 |
+
outputs="image",
|
29 |
live=True,
|
30 |
capture_session=True,
|
31 |
title="Texto para Imagem",
|
utils.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
def calculate_similarity():
|
4 |
+
image_features = embeddings[ModalityType.VISION]
|
5 |
+
text_features = embeddings[ModalityType.TEXT]
|
6 |
+
|
7 |
+
image_features /= image_features.norm(dim=-1, keepdim=True)
|
8 |
+
text_features /= text_features.norm(dim=-1, keepdim=True)
|
9 |
+
similarity = text_features.cpu().numpy() @ image_features.cpu().numpy().T
|