File size: 614 Bytes
c9485b7
 
0c71b1d
 
 
 
 
c9485b7
 
 
e6c4268
 
0c71b1d
c9485b7
e6c4268
0c71b1d
c9485b7
0c71b1d
 
 
e6c4268
c9485b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from flask import Flask, request, jsonify
from transformers import pipeline
import os

# Önemli: huggingface hub cache dizinini değiştir
os.environ['HF_HOME'] = '/tmp/huggingface'
os.environ['TRANSFORMERS_CACHE'] = '/tmp/transformers'

app = Flask(__name__)

classifier = pipeline("image-classification", model="ahmed792002/vit-plant-classification")

@app.route('/predict', methods=['POST'])
def predict():
    if 'image' not in request.files:
        return jsonify({'error': 'No image uploaded'}), 400

    image = request.files['image']
    predictions = classifier(image)
    return jsonify(predictions)