Krish30 commited on
Commit
843f2c1
·
verified ·
1 Parent(s): 071d0c9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -35
app.py DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env python
2
- # coding: utf-8
3
-
4
- # In[3]:
5
-
6
-
7
- import gradio as gr
8
- import tensorflow as tf
9
- import numpy as np
10
- import pickle
11
-
12
- # Load necessary objects from the pickle file
13
- with open('/content/drive/MyDrive/Oncoknow/Cancer /model_data_2.pkl', 'rb') as file:
14
- pickle_data = pickle.load(file)
15
-
16
- # Load the model
17
- model = pickle_data['model']
18
- class_names = ["CLL case lymphocytes", "Normal lymphocytes"]
19
-
20
- # Define function to preprocess and predict image
21
- def predict(image):
22
- img_array = tf.keras.preprocessing.image.img_to_array(image)
23
- img_array = tf.expand_dims(img_array, 0) # Create a batch of images
24
-
25
- predictions = model.predict(img_array)
26
- predicted_class = class_names[np.argmax(predictions[0])]
27
- confidence = round(100 * np.max(predictions[0]), 2)
28
-
29
- return predicted_class + f" ({confidence}%)"
30
-
31
- # Define Gradio Interface
32
- image = gr.Image(type='pil', label="Upload Image")
33
- label = gr.Label(label="Predicted Class")
34
-
35
- gr.Interface(predict, inputs=image, outputs=label, title="Cancer Classification App").launch()