Views
No views yet
openai/clip-vit-large-patch14)GET /healthPOST /predict
Content-Type: multipart/form-data
Form field: image (file)1{
2 "filename": "image.jpg",
3 "predicted_class": "Safe",
4 "predicted_index": 0,
5 "is_nsfw": false,
6 "confidence": 0.95,
7 "all_scores": {
8 "Safe": 0.95,
9 "NSFW Mild": 0.03,
10 "NSFW Explicit": 0.02
11 },
12 "status": "success"
13}POST /predict/batch
Content-Type: multipart/form-data
Form field: images (multiple files)[0.481, 0.458, 0.408] and std [0.269, 0.261, 0.276]1# Install dependencies
2pip install -r requirements.txt
3
4# Run the API
5python app.pyPORT environment variable.1docker build -t nsfw-classifier .
2docker run -p 7860:7860 nsfw-classifier1import requests
2
3with open("image.jpg", "rb") as f:
4 response = requests.post(
5 "http://localhost:7860/predict",
6 files={"image": f}
7 )
8print(response.json())