cang1602004 commited on
Commit
b4cfd02
·
verified ·
1 Parent(s): 1468d77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -15,22 +15,28 @@ CLASS_NAMES = ['bad', 'good', 'very_good']
15
  # KHẮC PHỤC LỖI TƯƠNG THÍCH PHIÊN BẢN (KERAS 3 -> KERAS 2)
16
  # =================================================================
17
 
18
- # 1. Mock DTypePolicy (Xử lý lỗi: Unknown dtype policy & Attribute name)
19
  class MockDTypePolicy:
20
  """
21
  Lớp giả lập để thay thế DTypePolicy của Keras 3.
22
  Giúp tránh lỗi deserialization khi chạy trên môi trường cũ.
23
  """
24
  def __init__(self, **kwargs):
25
- # SỬA LỖI: Thêm thuộc tính name để tránh AttributeError
26
  self.name = kwargs.get("name", "float32")
 
 
27
 
28
  @classmethod
29
  def from_config(cls, config):
30
  return cls(**config)
31
 
32
  def get_config(self):
33
- return {"name": self.name}
 
 
 
 
34
 
35
  # 2. Xử lý InputLayer (Xử lý lỗi: batch_shape)
36
  class FixedInputLayer(InputLayer):
 
15
  # KHẮC PHỤC LỖI TƯƠNG THÍCH PHIÊN BẢN (KERAS 3 -> KERAS 2)
16
  # =================================================================
17
 
18
+ # 1. Mock DTypePolicy (Xử lý lỗi: Unknown dtype policy, Attribute name & compute_dtype)
19
  class MockDTypePolicy:
20
  """
21
  Lớp giả lập để thay thế DTypePolicy của Keras 3.
22
  Giúp tránh lỗi deserialization khi chạy trên môi trường cũ.
23
  """
24
  def __init__(self, **kwargs):
25
+ # SỬA LỖI: Thêm đầy đủ các thuộc tính Keras 3 yêu cầu
26
  self.name = kwargs.get("name", "float32")
27
+ self.compute_dtype = kwargs.get("compute_dtype", "float32")
28
+ self.variable_dtype = kwargs.get("variable_dtype", "float32")
29
 
30
  @classmethod
31
  def from_config(cls, config):
32
  return cls(**config)
33
 
34
  def get_config(self):
35
+ return {
36
+ "name": self.name,
37
+ "compute_dtype": self.compute_dtype,
38
+ "variable_dtype": self.variable_dtype
39
+ }
40
 
41
  # 2. Xử lý InputLayer (Xử lý lỗi: batch_shape)
42
  class FixedInputLayer(InputLayer):