AIOmarRehan commited on
Commit
cca22e1
Β·
verified Β·
1 Parent(s): f70f418

Update app/gradio_app.py

Browse files
Files changed (1) hide show
  1. app/gradio_app.py +4 -3
app/gradio_app.py CHANGED
@@ -30,9 +30,10 @@ def classify_image(image):
30
  return image, {"error": f"Classification failed: {str(e)}"}
31
 
32
  def get_random_image():
33
- # Pick a random sample from the dataset
34
- sample = ds.shuffle(seed=random.randint(0, 9999))[0]
35
- img = sample["image"].convert("RGB") # just ensure RGB mode
 
36
  return img
37
 
38
  with gr.Blocks(title="Cats vs Dogs Classifier", theme=gr.themes.Soft()) as demo:
 
30
  return image, {"error": f"Classification failed: {str(e)}"}
31
 
32
  def get_random_image():
33
+ # Pick a random index from the entire dataset
34
+ idx = random.randint(0, len(ds) - 1)
35
+ sample = ds[idx]
36
+ img = sample["image"].convert("RGB") # ensure RGB mode
37
  return img
38
 
39
  with gr.Blocks(title="Cats vs Dogs Classifier", theme=gr.themes.Soft()) as demo: