Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -49,12 +49,14 @@ workflow_context = {
|
|
49 |
|
50 |
# Optimized parameters for HF Spaces
|
51 |
HF_OPTIMIZED_PARAMS = {
|
52 |
-
"iters":
|
53 |
-
"complexity":
|
54 |
-
"generations":
|
55 |
-
"population_size": 50, #
|
56 |
-
"
|
57 |
-
"
|
|
|
|
|
58 |
}
|
59 |
|
60 |
def parse_workflow_params(request: gr.Request) -> Dict[str, Any]:
|
@@ -223,20 +225,23 @@ def analyze_eis_optimized(
|
|
223 |
if progress_callback:
|
224 |
progress_callback(0.4, "Detecting circuit model...")
|
225 |
|
226 |
-
# Use simpler approach for HF
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
iters=params.get("iters", 20),
|
231 |
complexity=params.get("complexity", 8),
|
232 |
generations=params.get("generations", 15),
|
233 |
population_size=params.get("population_size", 50),
|
234 |
-
|
235 |
-
|
|
|
|
|
236 |
)
|
237 |
|
238 |
-
if
|
239 |
-
|
|
|
240 |
else:
|
241 |
circuit_str = "R0-[R1,C1]" # Fallback simple circuit
|
242 |
else:
|
@@ -456,11 +461,12 @@ def create_interface():
|
|
456 |
|
457 |
with gr.Row():
|
458 |
gr.Markdown("""
|
459 |
-
**
|
460 |
-
-
|
461 |
-
-
|
462 |
-
-
|
463 |
-
-
|
|
|
464 |
""")
|
465 |
|
466 |
# Results Tab
|
|
|
49 |
|
50 |
# Optimized parameters for HF Spaces
|
51 |
HF_OPTIMIZED_PARAMS = {
|
52 |
+
"iters": 30, # Increased for better circuit detection
|
53 |
+
"complexity": 10, # Increased for better circuit detection
|
54 |
+
"generations": 20, # Increased for better circuit detection
|
55 |
+
"population_size": 50, # Keep moderate for memory
|
56 |
+
"tol": 1e-3, # Tighter tolerance for better fits
|
57 |
+
"parallel": True, # Enable parallel processing
|
58 |
+
"terminals": "RLP", # R: resistor, L: inductor, P: constant-phase element
|
59 |
+
"seed": 42 # Random seed for reproducibility
|
60 |
}
|
61 |
|
62 |
def parse_workflow_params(request: gr.Request) -> Dict[str, Any]:
|
|
|
225 |
if progress_callback:
|
226 |
progress_callback(0.4, "Detecting circuit model...")
|
227 |
|
228 |
+
# Use simpler approach for HF - corrected parameter order and names
|
229 |
+
circuits_df = ae.core.generate_equivalent_circuits(
|
230 |
+
freq, # Frequency array (correct order)
|
231 |
+
Z, # Impedance array (correct order)
|
232 |
iters=params.get("iters", 20),
|
233 |
complexity=params.get("complexity", 8),
|
234 |
generations=params.get("generations", 15),
|
235 |
population_size=params.get("population_size", 50),
|
236 |
+
tol=params.get("tol", 1e-2),
|
237 |
+
parallel=params.get("parallel", True),
|
238 |
+
terminals=params.get("terminals", "RLP"),
|
239 |
+
seed=params.get("seed", 42)
|
240 |
)
|
241 |
|
242 |
+
if circuits_df is not None and len(circuits_df) > 0:
|
243 |
+
# Extract the best circuit string from the DataFrame
|
244 |
+
circuit_str = circuits_df.iloc[0]['circuitstring'] # Take the best circuit
|
245 |
else:
|
246 |
circuit_str = "R0-[R1,C1]" # Fallback simple circuit
|
247 |
else:
|
|
|
461 |
|
462 |
with gr.Row():
|
463 |
gr.Markdown("""
|
464 |
+
**HF-Optimized Settings (when enabled):**
|
465 |
+
- Circuit iterations: 30 (balanced performance/accuracy)
|
466 |
+
- Complexity limit: 10 (prevents overfitting)
|
467 |
+
- Population size: 50 (memory efficient)
|
468 |
+
- Tolerance: 1e-3 (good fit quality)
|
469 |
+
- Components: R (resistors), L (inductors), P (CPE)
|
470 |
""")
|
471 |
|
472 |
# Results Tab
|