|
from turtle import title |
|
import gradio as gr |
|
from transformers import pipeline |
|
from PIL import Image |
|
|
|
|
|
pipe = pipeline("image-classification", model="adonaivera/adonaivera/ofwat_defects_classification") |
|
|
|
def classify_image(image): |
|
|
|
PIL_image = Image.fromarray(image).convert('RGB') |
|
|
|
|
|
res = pipe(PIL_image) |
|
|
|
|
|
return {dic["label"]: dic["score"] for dic in res} |
|
|
|
|
|
iface = gr.Interface( |
|
classify_image, |
|
"image", |
|
"label", |
|
examples=[ |
|
["examples/CS.jpg"], |
|
["examples/GI.jpg"], |
|
["examples/PP.jpg"], |
|
["examples/RC.jpg"] |
|
], |
|
description="Upload an image to classify its material.", |
|
title="Material Classification with AI by Subterra" |
|
) |
|
|
|
|
|
iface.launch() |