nimatov commited on
Commit
22c088f
·
verified ·
1 Parent(s): 05ed13b

Update flask/Emotion_spotting_service.py

Browse files
Files changed (1) hide show
  1. flask/Emotion_spotting_service.py +17 -0
flask/Emotion_spotting_service.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import tensorflow.keras as keras
2
  import numpy as np
3
  import librosa
@@ -5,6 +6,22 @@ import random
5
  #import tensorflow_addons
6
  SAMPLE_RATE = 22050
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  class _Emotion_spotting_service():
9
  model = None
10
  #instance = None
 
1
+ import tensorflow as tf
2
  import tensorflow.keras as keras
3
  import numpy as np
4
  import librosa
 
6
  #import tensorflow_addons
7
  SAMPLE_RATE = 22050
8
 
9
+ import tensorflow as tf
10
+
11
+ gpus = tf.config.list_physical_devices('GPU')
12
+ if gpus:
13
+ try:
14
+ # Enable memory growth
15
+ for gpu in gpus:
16
+ tf.config.experimental.set_memory_growth(gpu, True)
17
+
18
+ # Optionally, set a memory limit
19
+ tf.config.set_logical_device_configuration(
20
+ gpus[0],
21
+ [tf.config.LogicalDeviceConfiguration(memory_limit=5120)]) # Set memory limit to 10GB
22
+ except RuntimeError as e:
23
+ print(e)
24
+
25
  class _Emotion_spotting_service():
26
  model = None
27
  #instance = None