vincentiusyoshuac commited on
Commit
aac343a
·
verified ·
1 Parent(s): 890d227

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -1
app.py CHANGED
@@ -2,7 +2,42 @@ import gradio as gr
2
  import torch
3
  import numpy as np
4
  import plotly.graph_objects as go
5
- from cognitive_net import DynamicCognitiveNet
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  class ModelDemo:
8
  def __init__(self):
@@ -87,6 +122,8 @@ with gr.Blocks(title="Cognitive Network Demo") as iface:
87
  - Adaptive structure
88
 
89
  Enter a sequence of numbers (comma-separated) to train the model to predict the next number.
 
 
90
  """)
91
 
92
  with gr.Row():
 
2
  import torch
3
  import numpy as np
4
  import plotly.graph_objects as go
5
+ from huggingface_hub import hf_hub_download
6
+ from pathlib import Path
7
+ import sys
8
+ import os
9
+
10
+ # Download model files from hub
11
+ def download_model_files():
12
+ files = ['memory.py', 'node.py', 'network.py', '__init__.py']
13
+ repo_id = "VLabTech/cognitive_net"
14
+
15
+ model_dir = Path('cognitive_net')
16
+ model_dir.mkdir(exist_ok=True)
17
+
18
+ for file in files:
19
+ try:
20
+ hf_hub_download(
21
+ repo_id=repo_id,
22
+ filename=file,
23
+ local_dir=model_dir
24
+ )
25
+ except Exception as e:
26
+ print(f"Error downloading {file}: {str(e)}")
27
+
28
+ # Add model directory to Python path
29
+ if str(model_dir.absolute()) not in sys.path:
30
+ sys.path.append(str(model_dir.absolute()))
31
+
32
+ # Download files and setup path
33
+ download_model_files()
34
+
35
+ # Now import the model
36
+ try:
37
+ from cognitive_net import DynamicCognitiveNet
38
+ except ImportError as e:
39
+ print(f"Error importing model: {str(e)}")
40
+ raise
41
 
42
  class ModelDemo:
43
  def __init__(self):
 
122
  - Adaptive structure
123
 
124
  Enter a sequence of numbers (comma-separated) to train the model to predict the next number.
125
+
126
+ Model: [VLabTech/cognitive_net](https://huggingface.co/VLabTech/cognitive_net)
127
  """)
128
 
129
  with gr.Row():