VishnuEcoClim commited on
Commit
a367aa2
·
1 Parent(s): 3373046

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -29,18 +29,18 @@ opt = st.selectbox("How do you want to upload the image for classification?", ('
29
  if opt == 'Upload image from device':
30
  file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
31
  if file is not None:
32
- file_Image = Image.open(file).resize((256, 256), Image.LANCZOS)
33
 
34
 
35
  elif opt == 'Upload image via link':
36
  img_url = st.text_input('Enter the Image Address')
37
  try:
38
- file_Image = Image.open(urllib.request.urlopen(img_url)).resize((256, 256), Image.LANCZOS)
39
  except ValueError:
40
  st.error("Please Enter a valid Image Address!")
41
 
42
  if 'image' in locals(): # Check if image variable exists
43
- st.image(file_Image, width=300, caption='Uploaded Image')
44
 
45
  if st.button('Predict'):
46
  try:
@@ -48,7 +48,7 @@ if 'image' in locals(): # Check if image variable exists
48
  st.info('Worked1')
49
 
50
  # Ensure image shape is correct and add batch dimension
51
- img_array = preprocess(file_Image) # This should return an array of shape (1, 256, 256, 3)
52
 
53
  st.info('Worked2')
54
 
 
29
  if opt == 'Upload image from device':
30
  file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
31
  if file is not None:
32
+ image = Image.open(file).resize((256, 256), Image.LANCZOS)
33
 
34
 
35
  elif opt == 'Upload image via link':
36
  img_url = st.text_input('Enter the Image Address')
37
  try:
38
+ image = Image.open(urllib.request.urlopen(img_url)).resize((256, 256), Image.LANCZOS)
39
  except ValueError:
40
  st.error("Please Enter a valid Image Address!")
41
 
42
  if 'image' in locals(): # Check if image variable exists
43
+ st.image(image, width=300, caption='Uploaded Image')
44
 
45
  if st.button('Predict'):
46
  try:
 
48
  st.info('Worked1')
49
 
50
  # Ensure image shape is correct and add batch dimension
51
+ img_array = preprocess(image) # This should return an array of shape (1, 256, 256, 3)
52
 
53
  st.info('Worked2')
54