Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| # --- ส่วนแก้ไขการ Import --- | |
| try: | |
| import gradio as gr | |
| except ImportError: | |
| # ถ้ายังไม่มี Gradio ให้ติดตั้งและ import ใหม่ | |
| print("=== ไม่พบ Gradio กำลังติดตั้ง... ===") | |
| os.system('pip install gradio --upgrade') | |
| import gradio as gr | |
| print("=== กำลังเชื่อมต่อกับ Space ต้นทาง (selfit-camera/omni-image-editor) ===") | |
| print("=== ระบบจะใช้ทรัพยากรจาก Space ต้นทาง ไม่ได้ใช้ GPU ของคุณ ===") | |
| # โหลด Interface จาก Space ต้นทาง | |
| # src="spaces" คือคีย์สำคัญที่บอกว่าให้ดึงหน้าเว็บมาแสดงผล ไม่ใช่โหลดโมเดลมาลงเครื่อง | |
| try: | |
| demo = gr.load(name="selfit-camera/omni-image-editor", src="spaces") | |
| except Exception as e: | |
| # เผื่อกรณีใส่ชื่อเต็มแล้ว error ให้ลองใส่แบบนี้ | |
| print(f"เกิดข้อผิดพลาดในการโหลดแบบแรก: {e}") | |
| print("กำลังลองโหลดด้วยวิธีสำรอง...") | |
| demo = gr.load(name="spaces/selfit-camera/omni-image-editor") | |
| # รันแอปพลิเคชัน | |
| if __name__ == "__main__": | |
| # ใน HF Space ไม่จำเป็นต้องใช้ share=True แต่ถ้าเผื่อรันใน Colab ก็ใส่ไว้ได้ | |
| demo.launch() |