ginipick commited on
Commit
97326af
·
verified ·
1 Parent(s): 10f1b51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -30
app.py CHANGED
@@ -31,21 +31,6 @@ def get_most_liked_spaces(limit: int = 100) -> Union[List[Dict], str]:
31
  except ValueError as e:
32
  return f"JSON decoding error: {str(e)}"
33
 
34
- def get_hardware_requirements(space: Dict) -> str:
35
- sdk = space.get('sdk', {})
36
- if isinstance(sdk, dict):
37
- hardware = sdk.get('hardware')
38
- if hardware:
39
- return hardware
40
-
41
- host_requirements = space.get('host_requirements', {})
42
- if isinstance(host_requirements, dict):
43
- hardware = host_requirements.get('hardware', {})
44
- if isinstance(hardware, dict):
45
- return 'CPU' if hardware.get('gpu') is False else 'GPU'
46
-
47
- return 'Unknown'
48
-
49
  def format_space(space: Dict) -> Dict:
50
  space_id = space.get('id', 'Unknown')
51
  space_name = space_id.split('/')[-1] if '/' in space_id else space_id
@@ -57,17 +42,12 @@ def format_space(space: Dict) -> Dict:
57
  space_likes = space.get('likes', 'N/A')
58
  space_url = f"https://huggingface.co/spaces/{space_id}"
59
 
60
- thumbnail_url = f"https://huggingface.co/spaces/{space_id}/resolve/main/thumbnail.png"
61
- hardware = get_hardware_requirements(space)
62
-
63
  return {
64
  "id": space_id,
65
  "name": space_name,
66
  "author": space_author,
67
  "likes": space_likes,
68
  "url": space_url,
69
- "thumbnail": thumbnail_url,
70
- "hardware": hardware
71
  }
72
 
73
  def format_spaces(spaces: Union[List[Dict], str]) -> List[Dict]:
@@ -109,7 +89,6 @@ def on_select(space):
109
  info = f"선택된 Space: {space['name']} (ID: {space['id']})\n"
110
  info += f"Author: {space['author']}\n"
111
  info += f"Likes: {space['likes']}\n"
112
- info += f"Hardware: {space['hardware']}\n"
113
  info += f"URL: {space['url']}\n\n"
114
  info += f"요약:\n{summary}"
115
  return info, app_content
@@ -128,12 +107,8 @@ def create_ui():
128
  footer {visibility: hidden;}
129
  .minimal-button {min-width: 30px !important; height: 25px !important; line-height: 1 !important; font-size: 12px !important; padding: 2px 5px !important;}
130
  .space-row {margin-bottom: 5px !important;}
131
- .thumbnail {width: 100px; height: 100px; object-fit: cover;}
132
- .hardware-info {font-size: 12px; color: #666;}
133
  """
134
 
135
- default_thumbnail = "https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
136
-
137
  with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
138
  gr.Markdown("# Hugging Face Most Liked Spaces")
139
 
@@ -142,13 +117,8 @@ def create_ui():
142
  space_rows = []
143
  for space in formatted_spaces:
144
  with gr.Row(elem_classes="space-row") as space_row:
145
- try:
146
- gr.Image(value=space['thumbnail'], width=100, height=100, show_label=False, elem_classes="thumbnail")
147
- except Exception:
148
- gr.Image(value=default_thumbnail, width=100, height=100, show_label=False, elem_classes="thumbnail")
149
  with gr.Column():
150
  gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
151
- gr.Markdown(f"Hardware: {space['hardware']}", elem_classes="hardware-info")
152
  button = gr.Button("클릭", elem_classes="minimal-button")
153
  space_rows.append((space_row, button, space))
154
 
 
31
  except ValueError as e:
32
  return f"JSON decoding error: {str(e)}"
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  def format_space(space: Dict) -> Dict:
35
  space_id = space.get('id', 'Unknown')
36
  space_name = space_id.split('/')[-1] if '/' in space_id else space_id
 
42
  space_likes = space.get('likes', 'N/A')
43
  space_url = f"https://huggingface.co/spaces/{space_id}"
44
 
 
 
 
45
  return {
46
  "id": space_id,
47
  "name": space_name,
48
  "author": space_author,
49
  "likes": space_likes,
50
  "url": space_url,
 
 
51
  }
52
 
53
  def format_spaces(spaces: Union[List[Dict], str]) -> List[Dict]:
 
89
  info = f"선택된 Space: {space['name']} (ID: {space['id']})\n"
90
  info += f"Author: {space['author']}\n"
91
  info += f"Likes: {space['likes']}\n"
 
92
  info += f"URL: {space['url']}\n\n"
93
  info += f"요약:\n{summary}"
94
  return info, app_content
 
107
  footer {visibility: hidden;}
108
  .minimal-button {min-width: 30px !important; height: 25px !important; line-height: 1 !important; font-size: 12px !important; padding: 2px 5px !important;}
109
  .space-row {margin-bottom: 5px !important;}
 
 
110
  """
111
 
 
 
112
  with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
113
  gr.Markdown("# Hugging Face Most Liked Spaces")
114
 
 
117
  space_rows = []
118
  for space in formatted_spaces:
119
  with gr.Row(elem_classes="space-row") as space_row:
 
 
 
 
120
  with gr.Column():
121
  gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
 
122
  button = gr.Button("클릭", elem_classes="minimal-button")
123
  space_rows.append((space_row, button, space))
124