File size: 1,082 Bytes
0c66420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
818640c
0c66420
818640c
0c66420
 
78a9d44
0c66420
 
 
 
 
 
 
 
 
 
 
 
902180b
0c66420
4b77703
bf74961
0c66420
 
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
import gradio as gr
import tensorflow as tf
from tensorflow.keras.applications import imagenet_utils
from tensorflow.keras.utils import img_to_array
from tensorflow.keras.models import load_model
import numpy as np
import cv2
import pickle





def Prediction_VGG16(image):
    
    #Prepare image
    IMG_SIZE = 224
    image = img_to_array(image)
    image = image*1.0/255.0
    img_prepared = image.reshape((-1,IMG_SIZE,IMG_SIZE,3))
    

    #Load model vgg6 package
    path = "model_vgg16.h5"
    my_model =load_model(path)



    #Prediction
    classes = ["Brain Tumor","Healthy"]
    prediction = my_model.predict(img_prepared)[0]
    prediction = prediction.tolist()


    return {k:v for k,v in zip(classes,prediction)}

css_code = 'body{background-image:url("https://picsum.photos/seed/picsum/200/300");}'

thumbnail = "https://github.com/gradio-app/hub-openpose/blob/master/screenshot.png?raw=true"
demo = gr.Interface(Prediction_VGG16, gr.inputs.Image(shape=(224,224)),gr.Label(num_top_classes=2),css= css_code ,theme="dark-peach",thumbnail =thumbnail )

demo.launch()