Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,14 +8,25 @@ from nltk.stem import WordNetLemmatizer
|
|
| 8 |
from transformers import pipeline
|
| 9 |
from PIL import Image
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 19 |
nltk.download('stopwords')
|
| 20 |
nltk.download('wordnet')
|
| 21 |
nltk.download('omw-1.4')
|
|
|
|
| 8 |
from transformers import pipeline
|
| 9 |
from PIL import Image
|
| 10 |
|
| 11 |
+
# Move set_page_config to the first line with a default layout
|
| 12 |
+
st.set_page_config(page_title="News Classifier", page_icon="📰", layout="wide")
|
| 13 |
+
|
| 14 |
+
# Function to detect device type
|
| 15 |
+
def detect_device():
|
| 16 |
+
user_agent = st.experimental_get_query_params().get("user_agent", [""])[0]
|
| 17 |
+
if "mobi" in user_agent.lower():
|
| 18 |
+
return "Mobile"
|
| 19 |
+
return "PC"
|
| 20 |
+
|
| 21 |
+
# Ask user for device preference (only if not already set)
|
| 22 |
+
if "device_type" not in st.session_state:
|
| 23 |
+
st.session_state.device_type = st.radio("Are you using a mobile device or a PC?", ["Mobile", "PC"])
|
| 24 |
+
|
| 25 |
+
# Adjust layout based on user selection
|
| 26 |
+
if st.session_state.device_type == "Mobile":
|
| 27 |
+
st.set_page_config(layout="centered") # Not needed if already set, but here for clarity
|
| 28 |
|
| 29 |
+
# Continue with the rest of the code
|
| 30 |
nltk.download('stopwords')
|
| 31 |
nltk.download('wordnet')
|
| 32 |
nltk.download('omw-1.4')
|