AMfeta99 commited on
Commit
65af555
1 Parent(s): c2f7672

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -19
app.py CHANGED
@@ -1,21 +1,6 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
  from PIL import Image
4
- #import os
5
-
6
- def load_images_from_current_directory():
7
- images = []
8
- current_directory = os.getcwd()
9
- for filename in os.listdir(current_directory):
10
- if filename.endswith(".jpg") or filename.endswith(".png"):
11
- img_path = os.path.join(current_directory, filename)
12
- img = Image.open(img_path)
13
- if img is not None:
14
- images.append(img)
15
- return images
16
-
17
- # Example: Load images from the current directory
18
- #example_images = load_images_from_current_directory()
19
 
20
  # Define the image classification function
21
  def classify_image(image):
@@ -57,11 +42,9 @@ article = "<p style='text-align: center'>Image Classification | Demo Model</p>"
57
 
58
 
59
  # Prepare examples with loaded images
60
- #examples = []
61
- #for img in example_images:
62
- # examples.append([np.array(img), os.path.basename(os.path.splitext(img.filename)[0])])
63
 
64
- demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, description=description, article=article, title=title)
65
 
66
  # Launch the Gradio interface
67
  demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
  from PIL import Image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  # Define the image classification function
6
  def classify_image(image):
 
42
 
43
 
44
  # Prepare examples with loaded images
45
+ examples = ["Normal_0.jpg", "Normal_1.jpg", "Normal_2.jpg", "Tumor_0.jpg", "Tumor_1.jpg", "Tumor_2.jpg"]
 
 
46
 
47
+ demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, description=description, article=article, title=title, examples=examples)
48
 
49
  # Launch the Gradio interface
50
  demo.launch()