File size: 1,010 Bytes
862b85f
7f0b6ea
 
 
0fc0313
7f0b6ea
 
ffef7f3
 
 
 
7f0b6ea
257266d
7f0b6ea
 
 
 
 
 
 
 
257266d
7f0b6ea
 
 
 
40d7ed8
cacead8
257266d
7f0b6ea
 
 
 
 
 
 
 
cacead8
7f0b6ea
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
import gradio as gr
import torch
from huggingface_hub import from_pretrained_fastai
from pathlib import Path

examples = ["akiec.jpg", 
            "mel.jpg",]
    # ⚠️ Type of model/library unknown.
  
   
repo_id = "Saim8250/Skin-Diseases-Classification"
path = Path("./")

def get_y(r):
    return r["label"]
    
def get_x(r):
    return path/r["fname"]
    
learner = from_pretrained_fastai(repo_id)
labels = learner.dls.vocab

def inference(image):
    label_predict,_,probs = learner.predict(image)
    labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
    return labels_probs
    


gr.Interface(
    fn=inference,
    title="Skin Diseases classification",
    description = "Predict which type of skin disease",
    inputs="image",
    examples=examples,
    outputs=gr.outputs.Label(num_top_classes=5, label='Prediction'),
    cache_examples=False,
    ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
).launch(debug=True, enable_queue=True)