Domeandreimno commited on
Commit
5977409
1 Parent(s): 06096af

Upload 3 files

Browse files
Files changed (3) hide show
  1. Dockerfile +20 -0
  2. app.py +15 -0
  3. requirements.txt +6 -0
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Usa l'immagine base ufficiale di Python
3
+ FROM python:3.8-slim
4
+
5
+ # Installa le dipendenze
6
+ COPY requirements.txt .
7
+ RUN pip install --upgrade pip
8
+ RUN pip install -r requirements.txt
9
+
10
+ # Copia i pesi del modello
11
+ COPY best.pt /app/best.pt
12
+
13
+ # Copia lo script di inferenza
14
+ COPY app.py /app/app.py
15
+
16
+ # Imposta la directory di lavoro
17
+ WORKDIR /app
18
+
19
+ # Comando per eseguire lo script di inferenza
20
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from ultralytics import YOLO
3
+ from flask import Flask, request, jsonify
4
+
5
+ app = Flask(__name__)
6
+ model = YOLO('best.pt')
7
+
8
+ @app.route('/predict', methods=['POST'])
9
+ def predict():
10
+ image = request.files['file'].read()
11
+ results = model(image)
12
+ return jsonify(results.pandas().xyxy[0].to_json(orient="records"))
13
+
14
+ if __name__ == '__main__':
15
+ app.run(host='0.0.0.0', port=8080)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ transformers
3
+ torch
4
+ torchvision
5
+ ultralytics
6
+ flask