File size: 1,438 Bytes
fb19eaf
a6d2687
 
fb19eaf
a6d2687
fb19eaf
a6d2687
 
fb19eaf
0670066
a6d2687
fb19eaf
c810027
fb19eaf
c810027
0670066
a6d2687
 
9d24fe4
a6d2687
 
 
 
41fe9e4
a6d2687
 
41fe9e4
 
a6d2687
 
 
 
fb19eaf
a6d2687
 
 
c810027
 
a6d2687
 
 
146d38a
a6d2687
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
import gradio as gr
from fastai.vision.all import *
import skimage

# Load the model
learn = load_learner('export.pkl')

# Get labels
labels = learn.dls.vocab

# Prediction function
def predict(img):
    # Resize the image inside the function (if required)
    img = PILImage.create(img)
    img = img.resize((512, 512))  # Resize image to (512, 512)
    pred, pred_idx, probs = learn.predict(img)
    prediction = str(pred)
    return prediction

# App configuration
title = "Breast cancer detection with Deep Transfer Learning(ResNet18)."
description = """
<p style='text-align: center'>
<b>Efficient and Explainable Framework for Breast Cancer Detect and Diagnose  By SANA ABDALJILI</b><be>
<b>As a radiologist or oncologist, it is crucial to know what is wrong with a breast x-ray image.</b><br>
<b>Upload the breast X-ray image to know what is wrong with a patient's breast with or without implant.</b><br>
This is a product of project of  software intelligence courses under professor Prof. Tiejian Luo
<br>
</p>
"""
article = "<p style='text-align: center'>Web app is built and managed by Addai Fosberg</p>"
examples = ['img1.jpeg', 'img2.jpeg']

# Update the interface components
gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),  # Use the 'type' argument instead of 'shape'
    outputs=gr.Label(num_top_classes=3),
    title=title,
    description=description,
    article=article,
    examples=examples
).launch()