Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -190,9 +190,9 @@ class SocialMediaAnalyzer:
|
|
| 190 |
# Get the predicted score
|
| 191 |
predicted_score = result['predicted_score']
|
| 192 |
|
| 193 |
-
# Convert score to angle (0-180 degrees, where 0 is
|
| 194 |
-
# Map 1-10 score to
|
| 195 |
-
angle = (predicted_score - 1) * 20 # 20 degrees per unit (180/9)
|
| 196 |
|
| 197 |
# Create the gauge
|
| 198 |
# Background circle (full range)
|
|
@@ -683,22 +683,22 @@ if __name__ == "__main__":
|
|
| 683 |
app = create_interface()
|
| 684 |
|
| 685 |
# Launch with automatic port finding
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
|
| 698 |
app.launch(
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
)
|
|
|
|
| 190 |
# Get the predicted score
|
| 191 |
predicted_score = result['predicted_score']
|
| 192 |
|
| 193 |
+
# Convert score to angle (0-180 degrees, where 0 is high addiction, 180 is low)
|
| 194 |
+
# Map 1-10 score to 180-0 degrees (reversed to match reversed colors)
|
| 195 |
+
angle = 180 - (predicted_score - 1) * 20 # 20 degrees per unit (180/9)
|
| 196 |
|
| 197 |
# Create the gauge
|
| 198 |
# Background circle (full range)
|
|
|
|
| 683 |
app = create_interface()
|
| 684 |
|
| 685 |
# Launch with automatic port finding
|
| 686 |
+
import socket
|
| 687 |
+
def find_free_port():
|
| 688 |
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
| 689 |
+
s.bind(('', 0))
|
| 690 |
+
s.listen(1)
|
| 691 |
+
port = s.getsockname()[1]
|
| 692 |
+
return port
|
| 693 |
|
| 694 |
+
port = find_free_port()
|
| 695 |
+
print(f"🚀 Launching app on port {port}")
|
| 696 |
+
print(f"📱 Access the app at: http://localhost:{port}")
|
| 697 |
|
| 698 |
app.launch(
|
| 699 |
+
server_name="0.0.0.0",
|
| 700 |
+
server_port=port,
|
| 701 |
+
share=False,
|
| 702 |
+
show_error=True,
|
| 703 |
+
quiet=False
|
| 704 |
)
|