Spaces:
Sleeping
Sleeping
Flavio de Oliveira
commited on
Commit
·
1b337ee
1
Parent(s):
815b94d
Get desired output
Browse files
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 |
-
|
|
|
56 |
else:
|
57 |
print('predict.txt does not exist')
|
58 |
|
59 |
-
return
|
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}"
|