Spaces:
Build error
Build error
initial commit
Browse files- app.py +38 -0
- car_damaged_or_not.ipynb +0 -0
- damage.jpg +0 -0
- damage_classifier.pkl +3 -0
- lambo.jpg +0 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: car_damaged_or_not.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['title', 'description', 'examples', 'learn', 'catogories', 'intf', 'predict']
|
| 5 |
+
|
| 6 |
+
# %% car_damaged_or_not.ipynb 1
|
| 7 |
+
# imports
|
| 8 |
+
# import os
|
| 9 |
+
# import timm
|
| 10 |
+
# import json
|
| 11 |
+
# import torch
|
| 12 |
+
import gradio as gr
|
| 13 |
+
# import pickle as pk
|
| 14 |
+
# from PIL import Image
|
| 15 |
+
|
| 16 |
+
import fastbook
|
| 17 |
+
fastbook.setup_book()
|
| 18 |
+
|
| 19 |
+
from fastbook import *
|
| 20 |
+
from fastai.vision.widgets import *
|
| 21 |
+
|
| 22 |
+
# %% car_damaged_or_not.ipynb 17
|
| 23 |
+
title = "Car Damage Identifier"
|
| 24 |
+
description = "A car damage classifier trained on images scraped from the web."
|
| 25 |
+
examples = ['lambo.jpg', 'damage.jpg']
|
| 26 |
+
|
| 27 |
+
learn = load_learner('damage_classifier.pkl')
|
| 28 |
+
|
| 29 |
+
# %% car_damaged_or_not.ipynb 18
|
| 30 |
+
catogories = ('Damaged','Not Damaged')
|
| 31 |
+
def predict(img):
|
| 32 |
+
img = PILImage.create(img)
|
| 33 |
+
pred,idx,probs = learn.predict(img)
|
| 34 |
+
return dict(zip(catogories, map(float, probs)))
|
| 35 |
+
|
| 36 |
+
# %% car_damaged_or_not.ipynb 19
|
| 37 |
+
intf = gr.Interface(fn=predict,inputs=gr.Image(),outputs=gr.Label(num_top_classes=2),title=title,description=description,examples=examples)
|
| 38 |
+
intf.launch(share=True)
|
car_damaged_or_not.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
damage.jpg
ADDED
|
damage_classifier.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a17db04ba7ca207465bde84b4d1f9b5b5bff1f43a9b5354a5bd65ab4eb516bd8
|
| 3 |
+
size 61165362
|
lambo.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|