victorpakholkov commited on
Commit
ae3c195
·
1 Parent(s): 1db7df1

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -77
app.py DELETED
@@ -1,77 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "322ba7dd",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "#!pip install ruamel.yaml\n",
11
- "\n",
12
- "#!pip install -Uqq fastai\n",
13
- "from fastai import *\n",
14
- "\n",
15
- "#!pip install torch\n",
16
- "\n",
17
- "#!pip install -Uqq scikit-image\n",
18
- "#!pip install -Uqq gradio\n",
19
- "\n",
20
- "#!pip install -Uqq pathlib\n",
21
- "\n",
22
- "from fastai.vision.all import *\n",
23
- "import pathlib\n",
24
- "temp = pathlib.PosixPath\n",
25
- "pathlib.PosixPath = pathlib.WindowsPath\n",
26
- "learn = load_learner('export.pkl')\n",
27
- "pathlib.PosixPath = temp\n",
28
- "\n",
29
- "labels = learn.dls.vocab\n",
30
- "def predict(img):\n",
31
- " img = PILImage.create(img)\n",
32
- " pred,pred_idx,probs = learn.predict(img)\n",
33
- " return {labels[i]: float(probs[i]) for i in range(len(labels))}\n",
34
- "\n",
35
- "import skimage\n",
36
- "title = \"Movie Poster Era Classifier\"\n",
37
- "description = \"This is a study project for models deployment via Gradio and HuggingFace Spaces. The app takes a movie poster as an input, returning probabilities of the poster being drawn either in 1900s-1960s, 1970s-1990s or later on. Pretrained resnet 101 was taken as a learner with being fine-tuned on 1500 posters of each period, retreived from DuckDuckGo search queries. Quality of the resulting model is quite low with 0.35 error rate after 11 epochs, but the aim was more to play around with Gradio, rather than crating working movie poster classifier. Full code for the model and deployment is featured on my GitHub page, linked below\"\n",
38
- "examples = ['example_1.jpeg', 'example_2.jpeg', 'example_3.jpeg']\n",
39
- "article=\"<p style='text-align: center'><a href='https://github.com/VictorPakholkov/movie_era_posters_detection_gradio_app' target='_blank'>Github repo</a></p>\"\n",
40
- "interpretation='default'\n",
41
- "enable_queue=True\n",
42
- "\n",
43
- "import gradio as gr\n",
44
- "gr.Interface(fn=predict,\n",
45
- " inputs=gr.inputs.Image(shape=(512, 512)),\n",
46
- " outputs=gr.outputs.Label(num_top_classes=3),\n",
47
- " title=title,\n",
48
- " description=description,\n",
49
- " article=article,\n",
50
- " examples=examples,\n",
51
- " interpretation=interpretation,\n",
52
- " enable_queue=enable_queue).launch(share=True)"
53
- ]
54
- }
55
- ],
56
- "metadata": {
57
- "kernelspec": {
58
- "display_name": "Python 3 (ipykernel)",
59
- "language": "python",
60
- "name": "python3"
61
- },
62
- "language_info": {
63
- "codemirror_mode": {
64
- "name": "ipython",
65
- "version": 3
66
- },
67
- "file_extension": ".py",
68
- "mimetype": "text/x-python",
69
- "name": "python",
70
- "nbconvert_exporter": "python",
71
- "pygments_lexer": "ipython3",
72
- "version": "3.9.13"
73
- }
74
- },
75
- "nbformat": 4,
76
- "nbformat_minor": 5
77
- }