Spaces:
Runtime error
Runtime error
altawil commited on
Update app.py
Browse files5 unmodified lines6789101112159 unmodified lines1721731741741751761771771781791791801811821831841801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613625 unmodified linesimport torchimport numpy as npfrom fastapi import FastAPI, HTTPExceptionfrom fastapi.responses import HTMLResponsefrom pydantic import BaseModelfrom torchvision import transformsfrom typing import List, Dict, Any, Optional159 unmodified lines return base64.b64encode(buffer).decode('utf-8')
# ================== نقاط نهاية الـ API ==================@app.get("/")@app.get("/", response_class=HTMLResponse)async def root(): """ نقطة البداية للـ API الصفحة الرئيسية للـ API """ return { "message": "InterFuser Self-Driving API", "version": "1.0.0", "status": "running", "active_sessions": len(SESSIONS) } html_content = f""" <!DOCTYPE html> <html dir="rtl" lang="ar"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>🚗 Baseer Self-Driving API</title> <style> * {{ margin: 0; padding: 0; box-sizing: border-box; }} body {{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }} .container {{ background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border-radius: 20px; padding: 40px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1); text-align: center; max-width: 600px; width: 100%; }} .logo {{ font-size: 4rem; margin-bottom: 20px; animation: bounce 2s infinite; }} @keyframes bounce {{ 0%, 20%, 50%, 80%, 100% {{ transform: translateY(0); }} 40% {{ transform: translateY(-10px); }} 60% {{ transform: translateY(-5px); }} }} h1 {{ color: #333; margin-bottom: 10px; font-size: 2.5rem; }} .subtitle {{ color: #666; margin-bottom: 30px; font-size: 1.2rem; }} .status {{ display: inline-block; background: #4CAF50; color: white; padding: 8px 16px; border-radius: 20px; margin: 10px 0; font-weight: bold; }} .stats {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; margin: 30px 0; }} .stat-card {{ background: #f8f9fa; padding: 20px; border-radius: 15px; border-left: 4px solid #667eea; }} .stat-number {{ font-size: 2rem; font-weight: bold; color: #667eea; }} .stat-label {{ color: #666; margin-top: 5px; }} .buttons {{ display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }} .btn {{ display: inline-block; padding: 12px 24px; border-radius: 25px; text-decoration: none; font-weight: bold; transition: all 0.3s ease; border: none; cursor: pointer; }} .btn-primary {{ background: #667eea; color: white; }} .btn-secondary {{ background: #6c757d; color: white; }} .btn:hover {{ transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); }} .features {{ text-align: right; margin-top: 30px; padding: 20px; background: #f8f9fa; border-radius: 15px; }} .features h3 {{ color: #333; margin-bottom: 15px; }} .features ul {{ list-style: none; padding: 0; }} .features li {{ padding: 5px 0; color: #666; }} .features li:before {{ content: "✅ "; margin-left: 10px; }} </style> </head> <body> <div class="container"> <div class="logo">🚗</div> <h1>Baseer Self-Driving API</h1> <p class="subtitle">نظام القيادة الذاتية المتقدم</p> <div class="status">🟢 يعمل بنجاح</div> <div class="stats"> <div class="stat-card"> <div class="stat-number">{len(SESSIONS)}</div> <div class="stat-label">الجلسات النشطة</div> </div> <div class="stat-card"> <div class="stat-number">v1.0</div> <div class="stat-label">الإصدار</div> </div> <div class="stat-card"> <div class="stat-number">FastAPI</div> <div class="stat-label">التقنية</div> </div> </div> <div class="buttons"> <a href="/docs" class="btn btn-primary">📚 توثيق API</a> <a href="/sessions" class="btn btn-secondary">📊 الجلسات</a> </div> <div class="features"> <h3>🌟 الميزات الرئيسية</h3> <ul> <li>نموذج InterFuser للقيادة الذاتية</li> <li>معالجة الصور في الوقت الفعلي</li> <li>اكتشاف الكائنات المرورية</li> <li>تحديد المسارات الذكية</li> <li>واجهة RESTful سهلة الاستخدام</li> <li>إدارة جلسات متعددة</li> </ul> </div> </div> </body> </html> """ return html_content
@app.post("/start_session", response_model=SessionResponse)async def start_session():app.py+183-8