FaizTech commited on
Commit
33f3c1a
·
verified ·
1 Parent(s): 0ae342a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -466,12 +466,28 @@ async def flutter_predict_endpoint(
466
  measurements_path=temp_measurements_path,
467
  target_point_list=target_point_list
468
  )
 
 
 
 
 
 
 
 
 
 
469
 
470
- # FastAPI لا يمكنه إرجاع كائن PIL مباشرة، يجب تحويله
471
- # يمكننا إعادته كـ Base64 أو حفظه وإرجاع مساره
472
- # للتبسيط، سنرجع فقط أوامر التحكم
473
- print(" Model execution successful. Returning control commands.")
474
- return commands_dict
 
 
 
 
 
 
475
 
476
  except gr.Error as e:
477
  # تحويل أخطاء Gradio إلى أخطاء HTTP
 
466
  measurements_path=temp_measurements_path,
467
  target_point_list=target_point_list
468
  )
469
+
470
+
471
+ # --- ✅ التعديل هنا ---
472
+ # تحويل صورة PIL إلى بيانات ثنائية في الذاكرة
473
+ buffered = io.BytesIO()
474
+ dashboard_pil.save(buffered, format="PNG")
475
+ # تشفير البيانات الثنائية إلى نص Base64
476
+ img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
477
+
478
+ print("✅ Model execution successful. Returning commands and Base64 image.")
479
 
480
+ # إرجاع كائن JSON يحتوي على كل من الأوامر والصورة المشفرة
481
+ return {
482
+ "control_commands": commands_dict,
483
+ "dashboard_image_base64": img_str
484
+ }
485
+
486
+ # # FastAPI لا يمكنه إرجاع كائن PIL مباشرة، يجب تحويله
487
+ # # يمكننا إعادته كـ Base64 أو حفظه وإرجاع مساره
488
+ # # للتبسيط، سنرجع فقط أوامر التحكم
489
+ # print("✅ Model execution successful. Returning control commands.")
490
+ # return commands_dict
491
 
492
  except gr.Error as e:
493
  # تحويل أخطاء Gradio إلى أخطاء HTTP