Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,6 @@ print(list_all_vqascore_models())
|
|
12 |
model_pipe = None
|
13 |
|
14 |
def initialize_model(model_name):
|
15 |
-
import torch
|
16 |
-
torch.jit.script = lambda f: f
|
17 |
print("Initializing model...")
|
18 |
global model_pipe
|
19 |
if model_pipe is None:
|
@@ -21,14 +19,16 @@ def initialize_model(model_name):
|
|
21 |
print("Model initialized!")
|
22 |
return model_pipe
|
23 |
|
|
|
|
|
24 |
@spaces.GPU
|
25 |
-
def generate(
|
26 |
-
|
27 |
-
return pipe(image, text)
|
28 |
|
29 |
iface = gr.Interface(
|
30 |
fn=generate, # function to call
|
31 |
-
inputs=[gr.Dropdown(["clip-flant5-xl", "clip-flant5-xxl"], label="Model Name"), gr.Image(type="pil"), gr.Textbox(label="Prompt")], # define the types of inputs
|
|
|
32 |
outputs="number", # define the type of output
|
33 |
title="VQAScore", # title of the app
|
34 |
description="This model evaluates the similarity between an image and a text prompt."
|
|
|
12 |
model_pipe = None
|
13 |
|
14 |
def initialize_model(model_name):
|
|
|
|
|
15 |
print("Initializing model...")
|
16 |
global model_pipe
|
17 |
if model_pipe is None:
|
|
|
19 |
print("Model initialized!")
|
20 |
return model_pipe
|
21 |
|
22 |
+
model_pipe = initialize_model("clip-flant5-xl")
|
23 |
+
|
24 |
@spaces.GPU
|
25 |
+
def generate(image, text):
|
26 |
+
return model_pipe(image, text)
|
|
|
27 |
|
28 |
iface = gr.Interface(
|
29 |
fn=generate, # function to call
|
30 |
+
# inputs=[gr.Dropdown(["clip-flant5-xl", "clip-flant5-xxl"], label="Model Name"), gr.Image(type="pil"), gr.Textbox(label="Prompt")], # define the types of inputs
|
31 |
+
inputs=[gr.Image(type="pil"), gr.Textbox(label="Prompt")], # define the types of inputs
|
32 |
outputs="number", # define the type of output
|
33 |
title="VQAScore", # title of the app
|
34 |
description="This model evaluates the similarity between an image and a text prompt."
|