Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ def get_recent_models(min_likes, days_ago, filter_substrings, search_substrings)
|
|
| 13 |
|
| 14 |
# Initialize an empty list to store the filtered models
|
| 15 |
recent_models = []
|
| 16 |
-
|
| 17 |
filter_substrings = [sub.strip().lower() for sub in filter_substrings.split(';')]
|
| 18 |
search_substrings = [term.strip().lower() for term in search_substrings.split(';')]
|
| 19 |
|
|
@@ -23,14 +23,47 @@ def get_recent_models(min_likes, days_ago, filter_substrings, search_substrings)
|
|
| 23 |
if hasattr(model, "created_at") and model.created_at:
|
| 24 |
# Ensure created_at is offset-naive
|
| 25 |
created_at_date = model.created_at.replace(tzinfo=None)
|
| 26 |
-
if
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
else:
|
| 35 |
# Since the models are sorted by likes in descending order,
|
| 36 |
# we can stop once we hit a model with 10 or fewer likes
|
|
|
|
| 13 |
|
| 14 |
# Initialize an empty list to store the filtered models
|
| 15 |
recent_models = []
|
| 16 |
+
|
| 17 |
filter_substrings = [sub.strip().lower() for sub in filter_substrings.split(';')]
|
| 18 |
search_substrings = [term.strip().lower() for term in search_substrings.split(';')]
|
| 19 |
|
|
|
|
| 23 |
if hasattr(model, "created_at") and model.created_at:
|
| 24 |
# Ensure created_at is offset-naive
|
| 25 |
created_at_date = model.created_at.replace(tzinfo=None)
|
| 26 |
+
if search_substrings != []:
|
| 27 |
+
if any(term in model.modelId.lower() for term in search_substrings):
|
| 28 |
+
if filter_substrings != []:
|
| 29 |
+
if not any(sub in model.modelId.lower() for sub in filter_substrings):
|
| 30 |
+
if created_at_date >= start_date:
|
| 31 |
+
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
| 32 |
+
recent_models.append({
|
| 33 |
+
"Model ID": f'<a href="https://huggingface.co/{model.modelId}" target="_blank">{model.modelId}</a>',
|
| 34 |
+
"Likes": model.likes,
|
| 35 |
+
"Creation Date": model.created_at.strftime("%Y-%m-%d %H:%M"),
|
| 36 |
+
"Task": task
|
| 37 |
+
})
|
| 38 |
+
else:
|
| 39 |
+
if created_at_date >= start_date:
|
| 40 |
+
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
| 41 |
+
recent_models.append({
|
| 42 |
+
"Model ID": f'<a href="https://huggingface.co/{model.modelId}" target="_blank">{model.modelId}</a>',
|
| 43 |
+
"Likes": model.likes,
|
| 44 |
+
"Creation Date": model.created_at.strftime("%Y-%m-%d %H:%M"),
|
| 45 |
+
"Task": task
|
| 46 |
+
})
|
| 47 |
+
else:
|
| 48 |
+
if filter_substrings != []:
|
| 49 |
+
if not any(sub in model.modelId.lower() for sub in filter_substrings):
|
| 50 |
+
if created_at_date >= start_date:
|
| 51 |
+
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
| 52 |
+
recent_models.append({
|
| 53 |
+
"Model ID": f'<a href="https://huggingface.co/{model.modelId}" target="_blank">{model.modelId}</a>',
|
| 54 |
+
"Likes": model.likes,
|
| 55 |
+
"Creation Date": model.created_at.strftime("%Y-%m-%d %H:%M"),
|
| 56 |
+
"Task": task
|
| 57 |
+
})
|
| 58 |
+
else:
|
| 59 |
+
if created_at_date >= start_date:
|
| 60 |
+
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
| 61 |
+
recent_models.append({
|
| 62 |
+
"Model ID": f'<a href="https://huggingface.co/{model.modelId}" target="_blank">{model.modelId}</a>',
|
| 63 |
+
"Likes": model.likes,
|
| 64 |
+
"Creation Date": model.created_at.strftime("%Y-%m-%d %H:%M"),
|
| 65 |
+
"Task": task
|
| 66 |
+
})
|
| 67 |
else:
|
| 68 |
# Since the models are sorted by likes in descending order,
|
| 69 |
# we can stop once we hit a model with 10 or fewer likes
|