Spaces:
Sleeping
Sleeping
Upload game_engine.py
Browse files- game_engine.py +38 -56
game_engine.py
CHANGED
|
@@ -38,63 +38,45 @@ print(f" SPACE_HARDWARE: {space_hardware}")
|
|
| 38 |
print(f" HF_SPACE: {hf_space}")
|
| 39 |
print(f" SPACE_AUTHOR_NAME: {space_author}")
|
| 40 |
|
| 41 |
-
#
|
|
|
|
| 42 |
try:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
create_white_canvas,
|
| 80 |
-
cleanup_memory,
|
| 81 |
-
log_memory_usage,
|
| 82 |
-
get_ocr_model_info
|
| 83 |
-
)
|
| 84 |
-
ocr_module = "cpu"
|
| 85 |
-
print("✅ Game Engine: Mode CPU - EasyOCR activé")
|
| 86 |
-
|
| 87 |
-
except ImportError:
|
| 88 |
-
from image_processing_cpu import (
|
| 89 |
-
recognize_number_fast_with_image,
|
| 90 |
-
create_thumbnail_fast,
|
| 91 |
-
create_white_canvas,
|
| 92 |
-
cleanup_memory,
|
| 93 |
-
log_memory_usage,
|
| 94 |
-
get_ocr_model_info
|
| 95 |
-
)
|
| 96 |
-
ocr_module = "cpu"
|
| 97 |
-
print("✅ Game Engine: Mode CPU - EasyOCR activé")
|
| 98 |
|
| 99 |
# Récupérer les infos du modèle sélectionné
|
| 100 |
try:
|
|
|
|
| 38 |
print(f" HF_SPACE: {hf_space}")
|
| 39 |
print(f" SPACE_AUTHOR_NAME: {space_author}")
|
| 40 |
|
| 41 |
+
# Test direct de l'import GPU avec debugging
|
| 42 |
+
print("🧪 Test import image_processing_gpu...")
|
| 43 |
try:
|
| 44 |
+
import image_processing_gpu
|
| 45 |
+
print("✅ Import image_processing_gpu réussi")
|
| 46 |
+
|
| 47 |
+
# Test de la fonction spécifique
|
| 48 |
+
print("🧪 Test fonction get_ocr_model_info...")
|
| 49 |
+
info = image_processing_gpu.get_ocr_model_info()
|
| 50 |
+
print(f"✅ OCR info: {info}")
|
| 51 |
+
|
| 52 |
+
# Si on arrive ici, l'import fonctionne
|
| 53 |
+
from image_processing_gpu import (
|
| 54 |
+
recognize_number_fast_with_image,
|
| 55 |
+
create_thumbnail_fast,
|
| 56 |
+
create_white_canvas,
|
| 57 |
+
cleanup_memory,
|
| 58 |
+
log_memory_usage,
|
| 59 |
+
get_ocr_model_info
|
| 60 |
+
)
|
| 61 |
+
ocr_module = "gpu"
|
| 62 |
+
print("✅ Game Engine: Mode GPU - TrOCR réussi !")
|
| 63 |
+
|
| 64 |
+
except Exception as e:
|
| 65 |
+
print(f"❌ Erreur import GPU: {e}")
|
| 66 |
+
import traceback
|
| 67 |
+
traceback.print_exc()
|
| 68 |
+
|
| 69 |
+
# Fallback CPU
|
| 70 |
+
from image_processing_cpu import (
|
| 71 |
+
recognize_number_fast_with_image,
|
| 72 |
+
create_thumbnail_fast,
|
| 73 |
+
create_white_canvas,
|
| 74 |
+
cleanup_memory,
|
| 75 |
+
log_memory_usage,
|
| 76 |
+
get_ocr_model_info
|
| 77 |
+
)
|
| 78 |
+
ocr_module = "cpu"
|
| 79 |
+
print("✅ Game Engine: Mode CPU - EasyOCR (fallback)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
# Récupérer les infos du modèle sélectionné
|
| 82 |
try:
|