File size: 835 Bytes
5f05cbc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from PIL import Image
import tensorflow as tf
import numpy as np

# Model load koro (example: EfficientNetB3)
model = tf.keras.models.load_model("model.h5")  # model.h5 file upload koro

# Class names (modify koro jodi dorkar hoy)
class_names = ["Monkeypox", "Not Monkeypox"]

def predict(image):
    # Image resize & preprocess (modify koro jodi dorkar hoy)
    img = image.resize((224, 224))
    img = np.array(img) / 255.0
    img = np.expand_dims(img, axis=0)
    pred = model.predict(img)
    label = class_names[np.argmax(pred)]
    confidence = np.max(pred)
    return f"{label} ({confidence*100:.2f}%)"

iface = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs="text",
    title="Monkeypox Detection",
    description="Upload a skin image to check for Monkeypox."
)

iface.launch()