2023-12-13 02:11:29 +01:00
|
|
|
from django.conf import settings
|
2024-01-14 23:12:35 +01:00
|
|
|
from roboflow import Roboflow
|
|
|
|
import os
|
2023-12-13 02:11:29 +01:00
|
|
|
|
2024-01-14 23:12:35 +01:00
|
|
|
rf = Roboflow(api_key=os.environ["API_KEY_ROBO"])
|
|
|
|
model = rf.workspace().project("plankton-vhsho").version(1).model
|
2023-12-13 02:11:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
def predict_image(image):
|
2024-01-14 23:12:35 +01:00
|
|
|
results = model.predict(image.image.path)
|
|
|
|
results.save(
|
|
|
|
f"{settings.MEDIA_ROOT}/{image.image.name.split('.')[0]}_predicted.{image.image.name.split('.')[-1]}"
|
2023-12-13 02:11:29 +01:00
|
|
|
)
|
2024-01-14 23:12:35 +01:00
|
|
|
return results.json()
|