Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
import pathlib
|
4 |
+
|
5 |
+
plt = platform.system()
|
6 |
+
if plt == 'Linux':
|
7 |
+
pathlib.WindowsPath = pathlib.PosixPath
|
8 |
+
|
9 |
+
learn = load_learner('movie_score_regression_resnet18.pkl')
|
10 |
+
|
11 |
+
def predict(img):
|
12 |
+
img = PILImage.create(img)
|
13 |
+
pred, _, _= learn.predict(img)
|
14 |
+
return str(round(pred[0], 1))
|
15 |
+
|
16 |
+
gr.Interface(
|
17 |
+
fn=predict,
|
18 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
19 |
+
outputs="text",
|
20 |
+
title= "Movie Poster Score Predictor",
|
21 |
+
interpretation='default',
|
22 |
+
enable_queue=True
|
23 |
+
).launch(inline=False)
|