Sephfox commited on
Commit
de9239a
·
verified ·
1 Parent(s): fb18efe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -15,6 +15,7 @@ import torch
15
  import cv2
16
  import mediapipe as mp
17
  import base64
 
18
 
19
 
20
  # Set page config
@@ -350,14 +351,18 @@ st.title("NeuraSense AI")
350
 
351
  # Set up DialoGPT model
352
  @st.cache_resource
353
- def load_model():
354
- tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
355
- model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
356
- return tokenizer, model
357
-
358
 
 
 
 
 
 
 
359
 
360
- tokenizer, model = load_model()
 
361
 
362
 
363
 
@@ -935,3 +940,6 @@ st.write("---")
935
  st.write("NeuraSense AI: Quantum-Enhanced Sensory Simulation v4.0")
936
  st.write("Disclaimer: This is an advanced simulation and does not represent current technological capabilities.""")
937
 
 
 
 
 
15
  import cv2
16
  import mediapipe as mp
17
  import base64
18
+ import gc
19
 
20
 
21
  # Set page config
 
351
 
352
  # Set up DialoGPT model
353
  @st.cache_resource
354
+ def load_tokenizer():
355
+ return AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
 
 
 
356
 
357
+ @st.cache_resource
358
+ def load_model():
359
+ model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium",
360
+ device_map="auto",
361
+ torch_dtype=torch.float16)
362
+ return model
363
 
364
+ tokenizer = load_tokenizer()
365
+ model = load_model()
366
 
367
 
368
 
 
940
  st.write("NeuraSense AI: Quantum-Enhanced Sensory Simulation v4.0")
941
  st.write("Disclaimer: This is an advanced simulation and does not represent current technological capabilities.""")
942
 
943
+ # After processing
944
+ torch.cuda.empty_cache()
945
+ gc.collect()