sikeaditya commited on
Commit
195f610
·
verified ·
1 Parent(s): d14f936

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -10
app.py CHANGED
@@ -16,19 +16,45 @@ import nest_asyncio
16
  nest_asyncio.apply()
17
 
18
  st.set_page_config(
19
- page_title="Plant Disease Classifier 🌱",
20
- page_icon="🌱",
21
- layout="wide",
22
- initial_sidebar_state="expanded",
23
  )
24
 
25
  # Custom CSS for styling
 
26
  custom_css = """
27
  <style>
28
- body { background-color: #f8f9fa; }
29
- h1, h2, h3, h4 { color: #2c3e50; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
30
- .stButton>button { background-color: #27ae60; color: white; border: none; padding: 0.5em 1em; border-radius: 5px; font-size: 16px; }
31
- .sidebar .sidebar-content { background-image: linear-gradient(#27ae60, #2ecc71); color: white; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </style>
33
  """
34
  st.markdown(custom_css, unsafe_allow_html=True)
@@ -221,14 +247,18 @@ def main():
221
  language_option = st.sidebar.radio("Language", options=["English", "Marathi"], index=0)
222
  st.session_state.language = language_option
223
  plant_type = st.sidebar.selectbox("Select Plant Type", options=['sugarcane', 'maize', 'cotton', 'rice', 'wheat'])
224
- uploaded_file = st.sidebar.file_uploader("Upload a plant image...", type=["jpg", "jpeg", "png"])
 
 
 
 
225
  st.title(translate_text("Krushi Mitra"))
226
  st.write(translate_text("Plant Disease Classification and Pesticide Recommendation.\n\nUpload an image, select plant type, and click on Classify."))
227
 
228
  if uploaded_file is not None:
229
  st.markdown("---")
230
  st.subheader(translate_text("Uploaded Image"))
231
- st.image(uploaded_file, use_container_width=True)
232
  if st.button(translate_text("Classify")):
233
  with st.spinner(translate_text("Classifying...")):
234
  predicted_class, pesticide = classify_image(plant_type, uploaded_file)
 
16
  nest_asyncio.apply()
17
 
18
  st.set_page_config(
19
+ page_title="Krushi Mitra 🌱",
20
+ page_icon="🌱",
21
+ layout="centered", # Change to centered layout
22
+ initial_sidebar_state="auto" # Auto-hide sidebar on small screens
23
  )
24
 
25
  # Custom CSS for styling
26
+ # Update custom CSS
27
  custom_css = """
28
  <style>
29
+ body {
30
+ background-color: #f0f2f6;
31
+ font-family: 'Inter', sans-serif;
32
+ }
33
+ .stApp {
34
+ max-width: 900px;
35
+ margin: 0 auto;
36
+ }
37
+ .stButton>button {
38
+ background-color: #2ecc71;
39
+ color: white;
40
+ border: none;
41
+ padding: 10px 20px;
42
+ border-radius: 8px;
43
+ font-weight: bold;
44
+ transition: all 0.3s ease;
45
+ }
46
+ .stButton>button:hover {
47
+ background-color: #27ae60;
48
+ transform: scale(1.05);
49
+ }
50
+ .stTabs [data-baseweb="tab-list"] {
51
+ background-color: #ecf0f1;
52
+ border-radius: 10px;
53
+ }
54
+ .stTabs [data-baseweb="tab"] {
55
+ padding: 10px 15px;
56
+ font-weight: 600;
57
+ }
58
  </style>
59
  """
60
  st.markdown(custom_css, unsafe_allow_html=True)
 
247
  language_option = st.sidebar.radio("Language", options=["English", "Marathi"], index=0)
248
  st.session_state.language = language_option
249
  plant_type = st.sidebar.selectbox("Select Plant Type", options=['sugarcane', 'maize', 'cotton', 'rice', 'wheat'])
250
+ uploaded_file = st.sidebar.file_uploader(
251
+ "Upload a plant image...",
252
+ type=["jpg", "jpeg", "png"],
253
+ help="Select an image of your plant to detect diseases"
254
+ )
255
  st.title(translate_text("Krushi Mitra"))
256
  st.write(translate_text("Plant Disease Classification and Pesticide Recommendation.\n\nUpload an image, select plant type, and click on Classify."))
257
 
258
  if uploaded_file is not None:
259
  st.markdown("---")
260
  st.subheader(translate_text("Uploaded Image"))
261
+ st.image(uploaded_file, width=300)
262
  if st.button(translate_text("Classify")):
263
  with st.spinner(translate_text("Classifying...")):
264
  predicted_class, pesticide = classify_image(plant_type, uploaded_file)