LuniLand commited on
Commit
c10c894
1 Parent(s): 8b6da13

Added req file

Browse files
Files changed (3) hide show
  1. .history/app_20221221161030.py +25 -0
  2. app.ipynb +4 -4
  3. requirements.txt +5 -0
.history/app_20221221161030.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'calssify_images']
5
+
6
+ # %% app.ipynb 2
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ # %% app.ipynb 3
11
+ learner = load_learner('model.pkl')
12
+
13
+ categories = ('Bird', 'Drone')
14
+
15
+ def calssify_images(img):
16
+ pred, idx, probs = learner.predict(img)
17
+ return dict(zip(categories, map(float, probs)))
18
+
19
+ # %% app.ipynb 4
20
+ image = gr.inputs.Image(shape = (192, 192))
21
+ label = gr.outputs.Label()
22
+ examples = ['BirdExample1.jpg', 'BirdExample2.jpg', 'DroneExample1.jpg', 'DroneExample2.jpg']
23
+
24
+ intf = gr.Interface(fn = calssify_images, inputs = image, outputs = label, examples = examples)
25
+ intf.launch(inline = False)
app.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 1,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -22,7 +22,7 @@
22
  },
23
  {
24
  "cell_type": "code",
25
- "execution_count": 8,
26
  "metadata": {},
27
  "outputs": [],
28
  "source": [
@@ -33,7 +33,7 @@
33
  },
34
  {
35
  "cell_type": "code",
36
- "execution_count": 13,
37
  "metadata": {},
38
  "outputs": [],
39
  "source": [
@@ -64,7 +64,7 @@
64
  },
65
  {
66
  "cell_type": "code",
67
- "execution_count": 18,
68
  "metadata": {},
69
  "outputs": [
70
  {
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 2,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
22
  },
23
  {
24
  "cell_type": "code",
25
+ "execution_count": 4,
26
  "metadata": {},
27
  "outputs": [],
28
  "source": [
 
33
  },
34
  {
35
  "cell_type": "code",
36
+ "execution_count": 5,
37
  "metadata": {},
38
  "outputs": [],
39
  "source": [
 
64
  },
65
  {
66
  "cell_type": "code",
67
+ "execution_count": 7,
68
  "metadata": {},
69
  "outputs": [
70
  {
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ -f https://download.pytorch.org/whl/torch_stable.html
2
+ torch==1.8.1+cpu
3
+ torchvision==0.9.1+cpu
4
+ fastai
5
+ ipywidgets