Spaces:
Sleeping
Sleeping
File size: 1,902 Bytes
883a6dd f6db76e 883a6dd f6db76e 883a6dd 9209ae3 6197827 883a6dd 25e6bc1 883a6dd fc44f04 883a6dd 6197827 178c061 f6db76e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# -*- coding: utf-8 -*-
"""Copy of app.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1KoR_JrJMqzUq-XagPaxVUp874bVW_qNI
"""
#/default_exp app
#
#from fastai.vision.all import *
#!pip install gradio
import gradio as gr
#/export
def is_monet(x): return x[0].issupper
#/export
from fastai.vision.all import *
#/export
learn = load_learner('model.pkl')
#/export
categories = ('Manet', 'Monet')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# export
image = gr.Image() # Image input without shape argument
label = gr.Label() # Label output
# Define some example images (make sure these paths are correct)
examples = ['monet.jpg', 'manet2.jpg', 'manet1.jpeg']
# Create the Gradio interface
#intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
# Create the Gradio interface with a title and description
intf = gr.Interface(
fn=classify_image,
inputs=image,
outputs=label,
examples=examples,
title="Monet vs Manet Image Classifier", # Add title here
description="Upload an image to classify it as either a Monet or Manet painting." # Optional description
)
# Launch the interface with Inline=False to open in a separate window
intf.launch(share=True)
#!pip install nbdev
import os
os.listdir('/content')
import os
notebook_path = '/content/app.ipynb'
print(os.path.abspath(notebook_path))
import os
file_exists = os.path.isfile('/content/app.ipynb')
print(file_exists) # This should return True if the file exists
import os
# Extract the path of the current notebook in Colab
notebook_path = '/content/app.ipynb' # Replace with the actual path if different
print(f"Notebook is located at: {notebook_path}")
nbdev.export.nb_export('Copy of app.ipynb', 'app')
print('Export successful')
|