Flavio de Oliveira commited on
Commit
1b337ee
·
1 Parent(s): 815b94d

Get desired output

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -52,11 +52,12 @@ def predict(input_image: Image.Image):
52
  # Read the output from predict.txt
53
  if os.path.exists('predict.txt'):
54
  with open('predict.txt', 'r') as f:
55
- output = f.read().strip().split('\n')[-1]
 
56
  else:
57
  print('predict.txt does not exist')
58
 
59
- return output
60
 
61
  except subprocess.CalledProcessError as e:
62
  return f"Command failed with error {e.returncode}"
 
52
  # Read the output from predict.txt
53
  if os.path.exists('predict.txt'):
54
  with open('predict.txt', 'r') as f:
55
+ output_line = f.read().strip().split('\n')[-1] # Last line
56
+ _, prediction = output_line.split(' ', 1) # split only at the first space
57
  else:
58
  print('predict.txt does not exist')
59
 
60
+ return prediction
61
 
62
  except subprocess.CalledProcessError as e:
63
  return f"Command failed with error {e.returncode}"