Ignaciobfp commited on
Commit
ebdfa45
verified
1 Parent(s): 1377acd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -11,13 +11,8 @@ labels = learner.dls.vocab
11
 
12
  # Funci贸n para realizar predicciones
13
  def predict(img):
14
- if isinstance(img, gr.Image):
15
- img_array = np.array(img)
16
- else:
17
- img_array = np.array(gr.Image.from_file(img))
18
-
19
  # Realizar la predicci贸n en la imagen proporcionada
20
- pred, pred_idx, probs = learner.predict(img_array)
21
 
22
  return {
23
  "Predictions": {labels[i]: float(probs[i]) for i in range(len(labels))},
@@ -29,9 +24,9 @@ image_dir = pathlib.Path('images')
29
  examples = [[path.as_posix()] for path in sorted(image_dir.glob('*.png'))]
30
 
31
  iface = gr.Interface(
32
- predict,
33
- gr.Image(type="pil"),
34
- "image",
35
- examples = examples,
36
  )
37
  iface.launch(share=False)
 
11
 
12
  # Funci贸n para realizar predicciones
13
  def predict(img):
 
 
 
 
 
14
  # Realizar la predicci贸n en la imagen proporcionada
15
+ pred, pred_idx, probs = learner.predict(img)
16
 
17
  return {
18
  "Predictions": {labels[i]: float(probs[i]) for i in range(len(labels))},
 
24
  examples = [[path.as_posix()] for path in sorted(image_dir.glob('*.png'))]
25
 
26
  iface = gr.Interface(
27
+ fnpredict,
28
+ inputs=gr.Image(label='Input', type='numpy'),
29
+ outputs=gr.Image(label='Output', height=600),
30
+ examples=examples,
31
  )
32
  iface.launch(share=False)