Ashendilantha commited on
Commit
48ec630
·
verified ·
1 Parent(s): 33dbcf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -8,20 +8,22 @@ from nltk.stem import WordNetLemmatizer
8
  from transformers import pipeline
9
  from PIL import Image
10
 
11
- # Check if device type is already stored
12
  if "device_type" not in st.session_state:
 
 
13
  # Ask user for device type
14
  device_type = st.radio("Are you using a mobile device or a PC?", ["Mobile", "PC"])
15
  st.session_state.device_type = device_type
16
  st.experimental_rerun() # Refresh the app to apply layout change
17
 
18
- # Set layout based on user selection
19
  if st.session_state.device_type == "Mobile":
20
  st.set_page_config(page_title="News Classifier", page_icon="📰", layout="centered")
21
  else:
22
  st.set_page_config(page_title="News Classifier", page_icon="📰", layout="wide")
23
 
24
- # Continue with the rest of the code
25
  nltk.download('stopwords')
26
  nltk.download('wordnet')
27
  nltk.download('omw-1.4')
 
8
  from transformers import pipeline
9
  from PIL import Image
10
 
11
+ # Ensure set_page_config is the first Streamlit command
12
  if "device_type" not in st.session_state:
13
+ st.set_page_config(page_title="News Classifier", page_icon="📰", layout="wide") # Default layout
14
+
15
  # Ask user for device type
16
  device_type = st.radio("Are you using a mobile device or a PC?", ["Mobile", "PC"])
17
  st.session_state.device_type = device_type
18
  st.experimental_rerun() # Refresh the app to apply layout change
19
 
20
+ # Apply the selected layout before anything else
21
  if st.session_state.device_type == "Mobile":
22
  st.set_page_config(page_title="News Classifier", page_icon="📰", layout="centered")
23
  else:
24
  st.set_page_config(page_title="News Classifier", page_icon="📰", layout="wide")
25
 
26
+ # Now continue with the rest of your code
27
  nltk.download('stopwords')
28
  nltk.download('wordnet')
29
  nltk.download('omw-1.4')