Spaces:
Running
Running
Update pages/Entorno de Ejecución.py
Browse files
pages/Entorno de Ejecución.py
CHANGED
@@ -57,12 +57,11 @@ with cnn:
|
|
57 |
@tf.function
|
58 |
def tf_predict(model_list, weights, img): #faster, but for few formats
|
59 |
y_gorrito = 0
|
60 |
-
weight_sum = sum(weights)
|
61 |
raw_img = tf.image.decode_image(img, channels=3)
|
62 |
img = tf.image.resize(raw_img,(IMAGE_WIDTH, IMAGE_HEIGHT))
|
63 |
for model, weight in zip(model_list, weights):
|
64 |
y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)*weight
|
65 |
-
return [y_gorrito /
|
66 |
|
67 |
def basic_predict(model_list, weights, img): #for non-supported formats
|
68 |
y_gorrito = 0
|
@@ -70,7 +69,7 @@ with cnn:
|
|
70 |
img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
|
71 |
for model, weight in zip(model_list, weights):
|
72 |
y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)*weight
|
73 |
-
return [y_gorrito /
|
74 |
|
75 |
def preprocess(file_uploader): #makes the uploaded image readable
|
76 |
img = np.frombuffer(uploaded_file.read(), np.uint8)
|
|
|
57 |
@tf.function
|
58 |
def tf_predict(model_list, weights, img): #faster, but for few formats
|
59 |
y_gorrito = 0
|
|
|
60 |
raw_img = tf.image.decode_image(img, channels=3)
|
61 |
img = tf.image.resize(raw_img,(IMAGE_WIDTH, IMAGE_HEIGHT))
|
62 |
for model, weight in zip(model_list, weights):
|
63 |
y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)*weight
|
64 |
+
return [y_gorrito / sum(weights, raw_img.numpy()]
|
65 |
|
66 |
def basic_predict(model_list, weights, img): #for non-supported formats
|
67 |
y_gorrito = 0
|
|
|
69 |
img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
|
70 |
for model, weight in zip(model_list, weights):
|
71 |
y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)*weight
|
72 |
+
return [y_gorrito / sum(weights), raw_img]
|
73 |
|
74 |
def preprocess(file_uploader): #makes the uploaded image readable
|
75 |
img = np.frombuffer(uploaded_file.read(), np.uint8)
|