hk-bt-rnd commited on
Commit
d27c7e7
·
1 Parent(s): f362c94

Update output gradio

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -39,7 +39,7 @@ def text_predictor(title, synopsis):
39
  for prob, cls in zip(genres, class_names):
40
  if prob >= 0.5:
41
  preds_name.append(cls)
42
- return {'score':round(score.item(), 2), 'award_winning':isAward.item(), "genres":preds_name}
43
 
44
  def img_predictor(img):
45
  # Preprocess the image
@@ -56,7 +56,7 @@ def img_predictor(img):
56
  if prob >= 0.5:
57
  preds_name.append(cls)
58
 
59
- return {'score':round(score.item(), 2), 'award_winning':isAward.item(), "genres":preds_name}
60
 
61
 
62
  def combine_predictor(title, synopsis, img):
@@ -83,14 +83,14 @@ def combine_predictor(title, synopsis, img):
83
  if prob >= 0.5:
84
  preds_name.append(cls)
85
 
86
- return {'score':round(score.item(), 2), 'award_winning':isAward.item(), "genres":preds_name}
87
 
88
  # iface_1 = gr.Interface(age_predictor_image, gr.Image(height=256, width=256), "json", examples=[["young.webp"], ["old.jpg"]])
89
- iface_1 = gr.Interface(text_predictor, [gr.Text(placeholder="Input title here"), gr.Text(placeholder="Input synopsis here")], ["json"])
90
 
91
- iface_2 = gr.Interface(img_predictor, gr.Image(height=224, width=224), ["json"])
92
 
93
- iface_3 = gr.Interface(combine_predictor, [gr.Text(placeholder="Input title here"), gr.Text(placeholder="Input synopsis here"), gr.Image(height=224, width=224)], ["json"])
94
  demo = gr.TabbedInterface([iface_1, iface_2, iface_3], ["From Text", "From Image", "From Text and Image"])
95
  demo.launch() # Launches the mini app!
96
 
 
39
  for prob, cls in zip(genres, class_names):
40
  if prob >= 0.5:
41
  preds_name.append(cls)
42
+ return round(score.item(), 2), isAward.item(), {"genres":preds_name}
43
 
44
  def img_predictor(img):
45
  # Preprocess the image
 
56
  if prob >= 0.5:
57
  preds_name.append(cls)
58
 
59
+ return round(score.item(), 2), isAward.item(), {"genres": preds_name}
60
 
61
 
62
  def combine_predictor(title, synopsis, img):
 
83
  if prob >= 0.5:
84
  preds_name.append(cls)
85
 
86
+ return round(score.item(), 2), isAward.item(), {"genres": preds_name}
87
 
88
  # iface_1 = gr.Interface(age_predictor_image, gr.Image(height=256, width=256), "json", examples=[["young.webp"], ["old.jpg"]])
89
+ iface_1 = gr.Interface(text_predictor, [gr.Text(placeholder="Input title here"), gr.Text(placeholder="Input synopsis here")], [gr.Label(label='Score'), gr.Label(label='Is Winning Award?'), "json"])
90
 
91
+ iface_2 = gr.Interface(img_predictor, gr.Image(height=224, width=224), [gr.Label(label='Score'), gr.Label(label='Is Winning Award?'), "json"])
92
 
93
+ iface_3 = gr.Interface(combine_predictor, [gr.Text(placeholder="Input title here"), gr.Text(placeholder="Input synopsis here"), gr.Image(height=224, width=224)], [gr.Label(label='Score'), gr.Label(label='Is Winning Award?'), "json"])
94
  demo = gr.TabbedInterface([iface_1, iface_2, iface_3], ["From Text", "From Image", "From Text and Image"])
95
  demo.launch() # Launches the mini app!
96