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

Update output gradio

Browse files
Files changed (2) hide show
  1. app.py +6 -6
  2. dockerfile +0 -30
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 round(score.item(), 2), 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 round(score.item(), 2), 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 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")], ["label", "label", "json"])
90
 
91
- iface_2 = gr.Interface(img_predictor, gr.Image(height=224, width=224), ["label", "label", "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)], ["label", "label", "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 {'score':round(score.item(), 2), 'award_winning':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 {'score':round(score.item(), 2), 'award_winning':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 {'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
 
dockerfile DELETED
@@ -1,30 +0,0 @@
1
- # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
-
4
- FROM python:3.9
5
-
6
- WORKDIR /code
7
-
8
- COPY ./requirements.txt ./requirements.txt
9
-
10
- COPY ./model_only.pt ./model_only.pt
11
-
12
- RUN pip install --no-cache-dir --upgrade -r ./requirements.txt
13
-
14
- # Set up a new user named "user" with user ID 1000
15
- RUN useradd -m -u 1000 user
16
-
17
- # Switch to the "user" user
18
- USER user
19
-
20
- # Set home to the user's home directory
21
- ENV HOME=/home/user \
22
- PATH=/home/user/.local/bin:$PATH
23
-
24
- # Set the working directory to the user's home directory
25
- WORKDIR $HOME/app
26
-
27
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
28
- COPY --chown=user . $HOME/app
29
-
30
- CMD ["python", "app.py"]