Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,6 +63,7 @@ def analyze_traffic(image_path):
|
|
| 63 |
logging.error(f"Error analyzing traffic: {e}")
|
| 64 |
return 0, "Error", "Error", None
|
| 65 |
|
|
|
|
| 66 |
# RL Optimization Class and Methods
|
| 67 |
class TrafficSimEnv(gym.Env):
|
| 68 |
def __init__(self, congestion_level):
|
|
@@ -129,7 +130,7 @@ class TrafficSimEnv(gym.Env):
|
|
| 129 |
def close(self):
|
| 130 |
pass
|
| 131 |
|
| 132 |
-
|
| 133 |
def optimize_signal_rl(congestion_level):
|
| 134 |
try:
|
| 135 |
# Map congestion levels (string to numeric)
|
|
@@ -156,7 +157,7 @@ def optimize_signal_rl(congestion_level):
|
|
| 156 |
for _ in range(10):
|
| 157 |
action, _ = model.predict(obs, deterministic=True)
|
| 158 |
obs, rewards, dones, _, infos = env.step(action)
|
| 159 |
-
|
| 160 |
# Debug observation structure
|
| 161 |
logging.debug(f"Step observation: {obs}, type: {type(obs)}, shape: {np.shape(obs)}")
|
| 162 |
|
|
|
|
| 63 |
logging.error(f"Error analyzing traffic: {e}")
|
| 64 |
return 0, "Error", "Error", None
|
| 65 |
|
| 66 |
+
# RL Optimization Class and Methods
|
| 67 |
# RL Optimization Class and Methods
|
| 68 |
class TrafficSimEnv(gym.Env):
|
| 69 |
def __init__(self, congestion_level):
|
|
|
|
| 130 |
def close(self):
|
| 131 |
pass
|
| 132 |
|
| 133 |
+
|
| 134 |
def optimize_signal_rl(congestion_level):
|
| 135 |
try:
|
| 136 |
# Map congestion levels (string to numeric)
|
|
|
|
| 157 |
for _ in range(10):
|
| 158 |
action, _ = model.predict(obs, deterministic=True)
|
| 159 |
obs, rewards, dones, _, infos = env.step(action)
|
| 160 |
+
|
| 161 |
# Debug observation structure
|
| 162 |
logging.debug(f"Step observation: {obs}, type: {type(obs)}, shape: {np.shape(obs)}")
|
| 163 |
|