File size: 948 Bytes
0a9b70a
 
 
 
 
 
 
3b7dfca
0a9b70a
058f162
9d0a537
0a9b70a
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import math
import numpy as np
import tensorflow as tf
from tensorflow import keras
import tensorflow_addons as tfa
import matplotlib.pyplot as plt
from tensorflow.keras import layers
from tensorflow.keras.models import load_model

from tensorflow import keras
model = keras.models.load_model('https://github.com/abdulkader902017/CervixNet/blob/6217a51b73ff30724d50712545b2b62bec8a754e/my_model/saved_model.pb')
response = requests.get("https://github.com/abdulkader902017/CervixNet/blob/main/labels.txt")
labels = response.text.split("\n")

def classify_image(inp):
  inp = inp.reshape((-1, 32, 32, 3))
  inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
  prediction = inception_net.predict(inp).flatten()
  confidences = {labels[i]: float(prediction[i]) for i in range(3)}
  return confidences

gr.Interface(fn=classify_image, 
             inputs=gr.Image(shape=(32, 32)),
             outputs=gr.Label(num_top_classes=3)).launch()