frncscp commited on
Commit
8839c56
·
1 Parent(s): 0c60a5f

Update pages/Entorno de Ejecución.py

Browse files
Files changed (1) hide show
  1. pages/Entorno de Ejecución.py +19 -18
pages/Entorno de Ejecución.py CHANGED
@@ -20,6 +20,22 @@ st.sidebar.write("contact@patacotron.tech")
20
 
21
  cnn, autoencoder, svm, iforest, gan, vit, zero_shot= st.tabs(["CNN", "Autoencoder", "OC-SVM", 'iForest', 'GAN', 'ViT', 'Zero-Shot'])
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  with cnn:
24
 
25
  col_a, col_b, = st.columns(2)
@@ -62,23 +78,6 @@ with cnn:
62
  threshold = st.slider('¿Cuál va a ser el límite donde se considere patacón? (el valor recomendado para Ultra-Patacotrón es 50%, para los demás, 75%-80%)', 0, 100, 50)
63
 
64
  selected_models = []
65
-
66
- def predict(model_list, weights, img): #for non-supported formats
67
- y_gorrito = 0
68
- raw_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
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, module = 'cv2'): #makes the uploaded image readable
75
- img = np.frombuffer(uploaded_file.read(), np.uint8)
76
- if module == 'cv2':
77
- img = cv2.imdecode(img, cv2.IMREAD_COLOR)
78
- elif module == 'pil':
79
- img = Image.frombuffer(data = uploaded_file.read())
80
- #img = Image.open(io.BytesIO(file_uploader.read()))
81
- return img
82
 
83
  # Set the image dimensions
84
  IMAGE_WIDTH = IMAGE_HEIGHT = 224
@@ -146,9 +145,11 @@ with vit:
146
  img = preprocess(uploaded_file, module = 'pil')
147
  raw_img = img
148
  img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
149
- classifier(img)
150
  else:
151
  st.write("Asegúrate de haber subido correctamente la imagen.")
 
 
 
152
 
153
  with zero_shot:
154
  st.write('Próximamente')
 
20
 
21
  cnn, autoencoder, svm, iforest, gan, vit, zero_shot= st.tabs(["CNN", "Autoencoder", "OC-SVM", 'iForest', 'GAN', 'ViT', 'Zero-Shot'])
22
 
23
+ def predict(model_list, weights, img): #for non-supported formats
24
+ y_gorrito = 0
25
+ raw_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
26
+ img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
27
+ for model, weight in zip(model_list, weights):
28
+ y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)*weight
29
+ return [y_gorrito / sum(weights), raw_img]
30
+
31
+ def preprocess(file_uploader, module = 'cv2'): #makes the uploaded image readable
32
+ img = np.frombuffer(uploaded_file.read(), np.uint8)
33
+ if module == 'cv2':
34
+ img = cv2.imdecode(img, cv2.IMREAD_COLOR)
35
+ elif module == 'pil':
36
+ img = Image.open(file_uploader.read())
37
+ return img
38
+
39
  with cnn:
40
 
41
  col_a, col_b, = st.columns(2)
 
78
  threshold = st.slider('¿Cuál va a ser el límite donde se considere patacón? (el valor recomendado para Ultra-Patacotrón es 50%, para los demás, 75%-80%)', 0, 100, 50)
79
 
80
  selected_models = []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  # Set the image dimensions
83
  IMAGE_WIDTH = IMAGE_HEIGHT = 224
 
145
  img = preprocess(uploaded_file, module = 'pil')
146
  raw_img = img
147
  img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
 
148
  else:
149
  st.write("Asegúrate de haber subido correctamente la imagen.")
150
+ with col_b:
151
+ st.write(classifier(img))
152
+ st.image(raw_img)
153
 
154
  with zero_shot:
155
  st.write('Próximamente')