burtenshaw commited on
Commit
f6c1bc9
·
1 Parent(s): 28cd729

update app with fall backs

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -17,7 +17,11 @@ def create_image(stats, username):
17
  space_activity = total_stats["Space Likes"]
18
 
19
  # Choose base image URL based on highest activity
20
- if model_activity >= max(dataset_activity, space_activity):
 
 
 
 
21
  url = "https://hub-recap.imglab-cdn.net/images/model.png"
22
  avatar = "Model Pro"
23
  elif dataset_activity >= max(model_activity, space_activity):
@@ -30,9 +34,8 @@ def create_image(stats, username):
30
  # Build text content with proper formatting
31
  text_parts = []
32
 
33
- # Header
34
  text_parts.append(
35
- f'<span size="12pt" weight="bold">Hugging Face ❤️ {username} in 2024</span>'
36
  )
37
  text_parts.append("") # Empty line for spacing
38
 
@@ -102,9 +105,9 @@ def create_image(stats, username):
102
  params = {
103
  "width": "1200",
104
  "text": text,
105
- "text-width": "800",
106
  "text-height": "600",
107
- "text-padding": "60",
108
  "text-color": "39,71,111",
109
  "text-x": "460",
110
  "text-y": "40",
@@ -112,7 +115,7 @@ def create_image(stats, username):
112
  "dpr": "2",
113
  }
114
 
115
- return f"{url}?{urlencode(params)}"
116
 
117
 
118
  def is_from_2024(created_at_str):
 
17
  space_activity = total_stats["Space Likes"]
18
 
19
  # Choose base image URL based on highest activity
20
+ # if everything is 0, we show the empty image
21
+ if model_activity == 0 and dataset_activity == 0 and space_activity == 0:
22
+ url = "https://hub-recap.imglab-cdn.net/images/empty.png"
23
+ avatar = "new! We couldn't find your stats on the Hub, maybe in 2025?"
24
+ elif model_activity >= max(dataset_activity, space_activity):
25
  url = "https://hub-recap.imglab-cdn.net/images/model.png"
26
  avatar = "Model Pro"
27
  elif dataset_activity >= max(model_activity, space_activity):
 
34
  # Build text content with proper formatting
35
  text_parts = []
36
 
 
37
  text_parts.append(
38
+ f'<span size="10pt" weight="bold">Hugging Face ❤️ {username} in 2024</span>'
39
  )
40
  text_parts.append("") # Empty line for spacing
41
 
 
105
  params = {
106
  "width": "1200",
107
  "text": text,
108
+ "text-width": "700",
109
  "text-height": "600",
110
+ "text-padding": "30",
111
  "text-color": "39,71,111",
112
  "text-x": "460",
113
  "text-y": "40",
 
115
  "dpr": "2",
116
  }
117
 
118
+ return f"{url}?{urlencode(params)}"
119
 
120
 
121
  def is_from_2024(created_at_str):