Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,10 +24,10 @@ data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
|
|
| 24 |
with open("labels.txt", "r") as file:
|
| 25 |
labels = file.read().splitlines()
|
| 26 |
|
| 27 |
-
def classify(Textbox, Textbox2, Textbox3):
|
| 28 |
if Textbox3 == code:
|
| 29 |
output = []
|
| 30 |
-
image_data = np.array(
|
| 31 |
image_data = cv.resize(image_data, (224, 224))
|
| 32 |
image_array = np.asarray(image_data)
|
| 33 |
normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
|
|
@@ -42,7 +42,6 @@ def classify(Textbox, Textbox2, Textbox3):
|
|
| 42 |
max_prediction_value = -1
|
| 43 |
|
| 44 |
print('Prediction')
|
| 45 |
-
|
| 46 |
|
| 47 |
Textbox2 = Textbox2.replace("[", "").replace("]", "").replace("'", "")
|
| 48 |
Textbox2 = Textbox2.split(",")
|
|
@@ -95,15 +94,16 @@ def classify(Textbox, Textbox2, Textbox3):
|
|
| 95 |
return "Unauthorized"
|
| 96 |
|
| 97 |
user_inputs = [
|
| 98 |
-
gr.inputs.Textbox(label="Textbox",type="text"),
|
| 99 |
-
gr.inputs.
|
| 100 |
-
gr.inputs.Textbox(label="
|
|
|
|
| 101 |
]
|
| 102 |
|
| 103 |
iface = gr.Interface(
|
| 104 |
fn=classify,
|
| 105 |
-
inputs
|
| 106 |
-
outputs=
|
| 107 |
title="Classifier",
|
| 108 |
)
|
| 109 |
iface.launch()
|
|
|
|
| 24 |
with open("labels.txt", "r") as file:
|
| 25 |
labels = file.read().splitlines()
|
| 26 |
|
| 27 |
+
def classify(Textbox, image_path, Textbox2, Textbox3):
|
| 28 |
if Textbox3 == code:
|
| 29 |
output = []
|
| 30 |
+
image_data = np.array(image_path)
|
| 31 |
image_data = cv.resize(image_data, (224, 224))
|
| 32 |
image_array = np.asarray(image_data)
|
| 33 |
normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
|
|
|
|
| 42 |
max_prediction_value = -1
|
| 43 |
|
| 44 |
print('Prediction')
|
|
|
|
| 45 |
|
| 46 |
Textbox2 = Textbox2.replace("[", "").replace("]", "").replace("'", "")
|
| 47 |
Textbox2 = Textbox2.split(",")
|
|
|
|
| 94 |
return "Unauthorized"
|
| 95 |
|
| 96 |
user_inputs = [
|
| 97 |
+
gr.inputs.Textbox(label="Textbox", type="text"),
|
| 98 |
+
gr.inputs.Image(),
|
| 99 |
+
gr.inputs.Textbox(label="Textbox2", type="text"),
|
| 100 |
+
gr.inputs.Textbox(label="Textbox3", type="password")
|
| 101 |
]
|
| 102 |
|
| 103 |
iface = gr.Interface(
|
| 104 |
fn=classify,
|
| 105 |
+
inputs=user_inputs,
|
| 106 |
+
outputs=gr.outputs.JSON(),
|
| 107 |
title="Classifier",
|
| 108 |
)
|
| 109 |
iface.launch()
|