zhiqiulin commited on
Commit
1fd93ff
·
verified ·
1 Parent(s): d59bd40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -3,7 +3,7 @@ import spaces
3
 
4
  import torch
5
  torch.jit.script = lambda f: f
6
- torch.autocast = lambda device_type, dtype: lambda f: f
7
 
8
  from t2v_metrics import VQAScore, list_all_vqascore_models
9
 
@@ -11,17 +11,17 @@ print(list_all_vqascore_models())
11
 
12
  # Initialize the model only once
13
  # if torch.cuda.is_available():
14
- # model_pipe = VQAScore(model="clip-flant5-xl", device="cpu") # our recommended scoring model
15
- # print("Model initialized!")
16
 
17
  @spaces.GPU
18
  def generate(model_name, image, text):
19
  # print("Model_name:", model_name)
20
  print("Image:", image)
21
  print("Text:", text)
22
- model_pipe = VQAScore(model="clip-flant5-xl") # our recommended scoring model
23
  # print("Model initialized, now moving to cuda")
24
- # model_pipe.to("cuda")
25
  print("Generating!")
26
  return model_pipe(images=[image], texts=[text])
27
 
 
3
 
4
  import torch
5
  torch.jit.script = lambda f: f
6
+ # torch.autocast = lambda device_type, dtype: lambda f: f
7
 
8
  from t2v_metrics import VQAScore, list_all_vqascore_models
9
 
 
11
 
12
  # Initialize the model only once
13
  # if torch.cuda.is_available():
14
+ model_pipe = VQAScore(model="clip-flant5-xl") # our recommended scoring model
15
+ print("Model initialized!")
16
 
17
  @spaces.GPU
18
  def generate(model_name, image, text):
19
  # print("Model_name:", model_name)
20
  print("Image:", image)
21
  print("Text:", text)
22
+ # model_pipe = VQAScore(model="clip-flant5-xl") # our recommended scoring model
23
  # print("Model initialized, now moving to cuda")
24
+ model_pipe.to("cuda")
25
  print("Generating!")
26
  return model_pipe(images=[image], texts=[text])
27