Dileep7729 commited on
Commit
7c06143
·
verified ·
1 Parent(s): 1aaff03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from transformers import CLIPModel, CLIPProcessor
3
  from PIL import Image
 
4
 
5
  # Step 1: Load Fine-Tuned Model from Hugging Face Model Hub
6
  model_name = "quadranttechnologies/retail-content-safety-clip-finetuned"
@@ -67,22 +68,9 @@ def classify_image(image):
67
  }
68
 
69
  except Exception as e:
70
- print(f"Error during classification: {e}")
71
- return {"Error": str(e)}
72
-
73
- # Step 3: Set Up Gradio Interface
74
- iface = gr.Interface(
75
- fn=classify_image,
76
- inputs=gr.Image(type="pil"),
77
- outputs=gr.Textbox(label="Output (Debug Mode)"), # Use Textbox to display errors if any occur
78
- title="Content Safety Classification",
79
- description="Upload an image to classify it as 'safe' or 'unsafe' with corresponding probabilities.",
80
- )
81
-
82
- # Step 4: Launch Gradio Interface
83
- if __name__ == "__main__":
84
- print("Launching the Gradio interface...")
85
- iface.launch()
86
 
87
 
88
 
 
1
  import gradio as gr
2
  from transformers import CLIPModel, CLIPProcessor
3
  from PIL import Image
4
+ import requests
5
 
6
  # Step 1: Load Fine-Tuned Model from Hugging Face Model Hub
7
  model_name = "quadranttechnologies/retail-content-safety-clip-finetuned"
 
68
  }
69
 
70
  except Exception as e:
71
+ # Log and return detailed error messages
72
+ print(f"Error during classification:
73
+
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
 
76