Spaces:
Sleeping
Sleeping
Update app.py
Browse files14 unmodified lines1516171819202122232425262728293031323334353614 unmodified lines# KHẮC PHỤC LỖI TƯƠNG THÍCH PHIÊN BẢN (KERAS 3 -> KERAS 2)# =================================================================# 1. Mock DTypePolicy (Xử lý lỗi: Unknown dtype policy & Attribute name)class MockDTypePolicy:"""Lớp giả lập để thay thế DTypePolicy của Keras 3.Giúp tránh lỗi deserialization khi chạy trên môi trường cũ."""def __init__(self, **kwargs):# SỬA LỖI: Thêm thuộc tính name để tránh AttributeErrorself.name = kwargs.get("name", "float32")@classmethoddef from_config(cls, config):return cls(**config)def get_config(self):return {"name": self.name}# 2. Xử lý InputLayer (Xử lý lỗi: batch_shape)class FixedInputLayer(InputLayer):14 unmodified lines1516171819202122232425262728293031323334353637383940414214 unmodified lines# KHẮC PHỤC LỖI TƯƠNG THÍCH PHIÊN BẢN (KERAS 3 -> KERAS 2)# =================================================================# 1. Mock DTypePolicy (Xử lý lỗi: Unknown dtype policy, Attribute name & compute_dtype)class MockDTypePolicy:"""Lớp giả lập để thay thế DTypePolicy của Keras 3.Giúp tránh lỗi deserialization khi chạy trên môi trường cũ."""def __init__(self, **kwargs):# SỬA LỖI: Thêm đầy đủ các thuộc tính mà Keras 3 yêu cầuself.name = kwargs.get("name", "float32")self.compute_dtype = kwargs.get("compute_dtype", "float32")self.variable_dtype = kwargs.get("variable_dtype", "float32")@classmethoddef from_config(cls, config):return cls(**config)def get_config(self):return {"name": self.name,"compute_dtype": self.compute_dtype,"variable_dtype": self.variable_dtype}# 2. Xử lý InputLayer (Xử lý lỗi: batch_shape)class FixedInputLayer(InputLayer):
app.py+9-3