Bernadetta14 commited on
Commit
fbaeee1
·
1 Parent(s): b3e18bc

Delete deploy (1).py

Browse files
Files changed (1) hide show
  1. deploy (1).py +0 -79
deploy (1).py DELETED
@@ -1,79 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Deploy
3
-
4
- Automatically generated by Colaboratory.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/drive/1bK9oazNpp0ELz8EATsAmWYgKaiUpdV3W
8
- """
9
-
10
- import os
11
-
12
- import tensorflow as tf
13
-
14
- import keras
15
- from keras.models import Sequential
16
- from keras.layers import Dense, Dropout, Flatten
17
- from keras.layers import Conv2D, MaxPooling2D, Conv3D, BatchNormalization
18
- from keras import backend as K
19
- from PIL import Image
20
- import numpy as np
21
-
22
- from sklearn.model_selection import train_test_split
23
- from sklearn.preprocessing import OneHotEncoder
24
-
25
- import matplotlib.pyplot as plt
26
- from matplotlib.pyplot import imshow
27
-
28
- import pandas as pd
29
- import zipfile
30
- from google.colab import files
31
-
32
- from tensorflow.keras.models import load_model
33
-
34
- model=load_model("/content/model.h5")
35
-
36
- !pip install gradio
37
- import gradio as gr
38
-
39
- pip install --upgrade gradio
40
-
41
- def trans_image(pillow_image):
42
- a = np.array(pillow_image.resize((128,128)))
43
- a = a.reshape(1,128,128,3)
44
- return a
45
-
46
- def brain(predict):
47
- if predict==0:
48
- return 'Glioma Tumor'
49
- elif predict==1:
50
- return 'Meningioma Tumor'
51
- elif predict==2:
52
- return 'No Tumor or Normal'
53
- else:
54
- return 'Pituitary Tumor'
55
-
56
- def predictions(x):
57
- a = model.predict(x)
58
- classi = np.where(a == np.amax(a))[1][0]
59
- return str(a[0][classi]*100), brain(classi)
60
-
61
- class_names = ['Glioma Tumor','Meningioma Tumor','No Tumor or Normal','Pituitary Tumor']
62
-
63
- import gradio
64
- import requests
65
-
66
- def predicts(img):
67
- img = img.reshape((1, 128, 128, 3))
68
- prediction = model.predict(img).flatten()
69
-
70
- return {class_names[i]: float(prediction[i]) for i in range(4)}
71
- image = gradio.inputs.Image(shape=(128, 128), source="upload")
72
- label = gr.outputs.Label(num_top_classes= 5)
73
-
74
- iface = gr.Interface(
75
- fn = predicts,
76
- inputs = image,
77
- outputs = label,
78
- )
79
- iface.launch(debug=True, share=True)