Spaces:
Runtime error
Runtime error
Final fix
Browse files
app.py
CHANGED
|
@@ -35,17 +35,16 @@ def predict_coordinates(text):
|
|
| 35 |
encoding = tokenizer(text, padding="max_length", truncation=True, \
|
| 36 |
max_length=128, return_tensors='pt')
|
| 37 |
outputs = coordinates_model(**encoding)
|
| 38 |
-
|
| 39 |
-
return outputs[0][0][0], outputs[0][0][1]
|
| 40 |
|
| 41 |
def predict(text):
|
| 42 |
text = process_tweet(text)
|
| 43 |
relevancy_label, relevancy_score = predict_relevancy(text)
|
| 44 |
if relevancy_label == 'relevant':
|
| 45 |
lat, lon = predict_coordinates(text)
|
| 46 |
-
return f"
|
| 47 |
-
f"
|
| 48 |
-
return f"
|
| 49 |
|
| 50 |
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
| 51 |
iface.launch()
|
|
|
|
| 35 |
encoding = tokenizer(text, padding="max_length", truncation=True, \
|
| 36 |
max_length=128, return_tensors='pt')
|
| 37 |
outputs = coordinates_model(**encoding)
|
| 38 |
+
return round(outputs[0][0][0], 3), round(outputs[0][0][1], 3)
|
|
|
|
| 39 |
|
| 40 |
def predict(text):
|
| 41 |
text = process_tweet(text)
|
| 42 |
relevancy_label, relevancy_score = predict_relevancy(text)
|
| 43 |
if relevancy_label == 'relevant':
|
| 44 |
lat, lon = predict_coordinates(text)
|
| 45 |
+
return f"Confident for {round(relevancy_score * 100, 2)}% that tweet has the geolocation relevant information.\n" + \
|
| 46 |
+
f"Predicted coordinates are: lat: {lat} lon: {lon}"
|
| 47 |
+
return f"Confident for {relevancy_score * 100}% that tweet does not have the geolocation relevant information."
|
| 48 |
|
| 49 |
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
| 50 |
iface.launch()
|