Spaces:
Runtime error
Runtime error
Update processing.py
Browse files- processing.py +10 -3
processing.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import os
|
| 2 |
import dgl
|
| 3 |
import torch
|
| 4 |
import torch.nn as nn
|
|
@@ -34,6 +34,12 @@ def process_file(file):
|
|
| 34 |
combination_name = file.name.replace('.json', '')
|
| 35 |
|
| 36 |
for site in site_data:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
try:
|
| 38 |
site['children_id'] = ast.literal_eval(site['children_id'])
|
| 39 |
site['angle_node_children'] = ast.literal_eval(site['angle_node_children'])
|
|
@@ -41,7 +47,8 @@ def process_file(file):
|
|
| 41 |
except Exception as e:
|
| 42 |
return f"Error processing site data: {e}", None
|
| 43 |
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
src_nodes = []
|
| 47 |
dst_nodes = []
|
|
@@ -97,7 +104,7 @@ def process_file(file):
|
|
| 97 |
g.edata['weight'] = torch.tensor(edge_weights, dtype=torch.float32)
|
| 98 |
|
| 99 |
graphs[unique_key] = g
|
| 100 |
-
print(f'Processed graph for
|
| 101 |
|
| 102 |
try:
|
| 103 |
# Load the model with the custom class
|
|
|
|
| 1 |
+
import os
|
| 2 |
import dgl
|
| 3 |
import torch
|
| 4 |
import torch.nn as nn
|
|
|
|
| 34 |
combination_name = file.name.replace('.json', '')
|
| 35 |
|
| 36 |
for site in site_data:
|
| 37 |
+
# Check if all required fields are present
|
| 38 |
+
required_fields = ['children_id', 'angle_node_children', 'edge_length', 'num_children', 'x_coordinate', 'y_coordinate', 'z_coordinate', 'area', 'volume', 'avg_normals_x', 'avg_normals_y', 'avg_normals_z', 'bb_depth', 'bb_width', 'bb_height', 'surface_area', 'density', 'vertices_faces_ratio', 'vertices_edges_ratio', 'prevailing_wind', 'avg_wind_m/s', 'yearly_overall_sun_h', 'yearly_overall_radiation_wh/sqm', 'yearly_avg_temp', 'min_temp', 'max_temp', 'node_id']
|
| 39 |
+
missing_fields = [field for field in required_fields if field not in site]
|
| 40 |
+
if missing_fields:
|
| 41 |
+
return f"Missing fields in site data: {missing_fields}", None
|
| 42 |
+
|
| 43 |
try:
|
| 44 |
site['children_id'] = ast.literal_eval(site['children_id'])
|
| 45 |
site['angle_node_children'] = ast.literal_eval(site['angle_node_children'])
|
|
|
|
| 47 |
except Exception as e:
|
| 48 |
return f"Error processing site data: {e}", None
|
| 49 |
|
| 50 |
+
# Use prevailing_wind instead of site_id
|
| 51 |
+
unique_key = f"{site['prevailing_wind']}_{combination_name}"
|
| 52 |
|
| 53 |
src_nodes = []
|
| 54 |
dst_nodes = []
|
|
|
|
| 104 |
g.edata['weight'] = torch.tensor(edge_weights, dtype=torch.float32)
|
| 105 |
|
| 106 |
graphs[unique_key] = g
|
| 107 |
+
print(f'Processed graph for prevailing wind {site["prevailing_wind"]} from {file.name}: {g.num_nodes()} nodes, {g.num_edges()} edges.')
|
| 108 |
|
| 109 |
try:
|
| 110 |
# Load the model with the custom class
|