ginipick commited on
Commit
718118e
·
verified ·
1 Parent(s): 95523ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -50,6 +50,13 @@ def capture_thumbnail(space_id: str) -> bytes:
50
  pass
51
  return None
52
 
 
 
 
 
 
 
 
53
  def format_space(space: Dict) -> Dict:
54
  space_id = space.get('id', 'Unknown')
55
  space_name = space_id.split('/')[-1] if '/' in space_id else space_id
@@ -62,6 +69,7 @@ def format_space(space: Dict) -> Dict:
62
  space_url = f"https://huggingface.co/spaces/{space_id}"
63
 
64
  thumbnail = capture_thumbnail(space_id)
 
65
 
66
  return {
67
  "id": space_id,
@@ -69,7 +77,8 @@ def format_space(space: Dict) -> Dict:
69
  "author": space_author,
70
  "likes": space_likes,
71
  "url": space_url,
72
- "thumbnail": thumbnail
 
73
  }
74
 
75
  def format_spaces(spaces: Union[List[Dict], str]) -> List[Dict]:
@@ -126,6 +135,10 @@ def create_ui():
126
  height: 100px;
127
  object-fit: cover;
128
  }
 
 
 
 
129
  """
130
 
131
  def on_select(space):
@@ -135,6 +148,7 @@ def create_ui():
135
  info = f"선택된 Space: {space['name']} (ID: {space['id']})\n"
136
  info += f"Author: {space['author']}\n"
137
  info += f"Likes: {space['likes']}\n"
 
138
  info += f"URL: {space['url']}\n\n"
139
  info += f"요약:\n{summary}"
140
  return info, app_content
@@ -157,6 +171,7 @@ def create_ui():
157
  gr.Image(value="https://huggingface.co/front/assets/huggingface_logo-noborder.svg", shape=(100, 100), show_label=False, elem_classes="thumbnail")
158
  with gr.Column():
159
  gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
 
160
  button = gr.Button("클릭", elem_classes="minimal-button")
161
  space_rows.append((space_row, button, space))
162
 
 
50
  pass
51
  return None
52
 
53
+ def get_hardware_requirements(space: Dict) -> str:
54
+ sdk_version = space.get('sdk', {}).get('hf', {}).get('version')
55
+ if sdk_version and int(sdk_version.split('.')[0]) >= 3:
56
+ return space.get('sdk', {}).get('hardware', 'Unknown')
57
+ else:
58
+ return 'CPU' if space.get('host_requirements', {}).get('hardware', {}).get('gpu') is False else 'GPU'
59
+
60
  def format_space(space: Dict) -> Dict:
61
  space_id = space.get('id', 'Unknown')
62
  space_name = space_id.split('/')[-1] if '/' in space_id else space_id
 
69
  space_url = f"https://huggingface.co/spaces/{space_id}"
70
 
71
  thumbnail = capture_thumbnail(space_id)
72
+ hardware = get_hardware_requirements(space)
73
 
74
  return {
75
  "id": space_id,
 
77
  "author": space_author,
78
  "likes": space_likes,
79
  "url": space_url,
80
+ "thumbnail": thumbnail,
81
+ "hardware": hardware
82
  }
83
 
84
  def format_spaces(spaces: Union[List[Dict], str]) -> List[Dict]:
 
135
  height: 100px;
136
  object-fit: cover;
137
  }
138
+ .hardware-info {
139
+ font-size: 12px;
140
+ color: #666;
141
+ }
142
  """
143
 
144
  def on_select(space):
 
148
  info = f"선택된 Space: {space['name']} (ID: {space['id']})\n"
149
  info += f"Author: {space['author']}\n"
150
  info += f"Likes: {space['likes']}\n"
151
+ info += f"Hardware: {space['hardware']}\n"
152
  info += f"URL: {space['url']}\n\n"
153
  info += f"요약:\n{summary}"
154
  return info, app_content
 
171
  gr.Image(value="https://huggingface.co/front/assets/huggingface_logo-noborder.svg", shape=(100, 100), show_label=False, elem_classes="thumbnail")
172
  with gr.Column():
173
  gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
174
+ gr.Markdown(f"Hardware: {space['hardware']}", elem_classes="hardware-info")
175
  button = gr.Button("클릭", elem_classes="minimal-button")
176
  space_rows.append((space_row, button, space))
177