33 lines
1.3 KiB
Plaintext
33 lines
1.3 KiB
Plaintext
|
|
from huggingface_hub import HfApi
|
||
|
|
api = HfApi()
|
||
|
|
import itertools
|
||
|
|
results = api.list_models(expand=["author","spaces","siblings","transformersInfo","lastModified","disabled","trendingScore","safetensors","widgetData","sha"])
|
||
|
|
for tmp in itertools.islice(results, 5):
|
||
|
|
# 获取模型的详细信息
|
||
|
|
model = api.model_info(tmp.id)
|
||
|
|
|
||
|
|
# 定义一个函数来比较两个对象的属性
|
||
|
|
def compare_attributes(obj1, obj2):
|
||
|
|
# 获取两个对象的所有属性
|
||
|
|
attrs1 = {attr: getattr(obj1, attr) for attr in dir(obj1) if not callable(getattr(obj1, attr)) and not attr.startswith("__")}
|
||
|
|
attrs2 = {attr: getattr(obj2, attr) for attr in dir(obj2) if not callable(getattr(obj2, attr)) and not attr.startswith("__")}
|
||
|
|
|
||
|
|
# 比较属性值
|
||
|
|
differences = {}
|
||
|
|
for key in set(attrs1.keys()).union(attrs2.keys()):
|
||
|
|
value1 = attrs1.get(key)
|
||
|
|
value2 = attrs2.get(key)
|
||
|
|
if value1 != value2:
|
||
|
|
differences[key] = (value1, value2)
|
||
|
|
|
||
|
|
return differences
|
||
|
|
|
||
|
|
# 比较tmp和model的属性
|
||
|
|
differences = compare_attributes(tmp, model)
|
||
|
|
|
||
|
|
# 打印出不一致的属性及它们的值
|
||
|
|
if differences:
|
||
|
|
print(f"ID: {tmp.id}")
|
||
|
|
for key, (value_tmp, value_model) in differences.items():
|
||
|
|
print(f" Key: {key} is different-tmp:{value_tmp}")
|