Spaces:
Sleeping
Sleeping
File size: 883 Bytes
90dc1e2 d025638 90dc1e2 d025638 90dc1e2 9f24354 90dc1e2 1f247cc 90dc1e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from ultralytics import YOLO
import cv2
# Laden Sie das YOLO-Modell
model = YOLO('yolov8m-seg.pt')
# Funktion für die Vorhersage und Rückgabe des bearbeiteten Bildes
def predict_and_visualize(image):
# Führen Sie die Vorhersage durch
prediction = model.predict(image, imgsz=(1024, 1024), show=False, save=True)
# Nehmen Sie das generierte Bild, das von YOLO gespeichert wurde
processed_image_path = prediction.__getitem__(0).save_dir + "/" +prediction.__getitem__(0).path
print(processed_image_path)
#print("Image PATH: ",processed_image_path)
# Laden Sie das Bild und geben Sie es zurück
processed_image = cv2.imread(processed_image_path)
return processed_image
# Gradio-Schnittstelle für die Bildbearbeitungsfunktion
iface = gr.Interface(fn=predict_and_visualize, inputs="image", outputs="image")
iface.launch()
|