import gradio as gr import requests import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from datetime import datetime, timedelta import plotly.graph_objects as go import numpy as np import json # 관심 스페이스 URL 리스트와 정보 target_spaces = { "ginipick/FLUXllama": "https://huggingface.co/spaces/ginipick/FLUXllama", "ginipick/SORA-3D": "https://huggingface.co/spaces/ginipick/SORA-3D", "fantaxy/Sound-AI-SFX": "https://huggingface.co/spaces/fantaxy/Sound-AI-SFX", "fantos/flx8lora": "https://huggingface.co/spaces/fantos/flx8lora", "ginigen/Canvas": "https://huggingface.co/spaces/ginigen/Canvas", "fantaxy/erotica": "https://huggingface.co/spaces/fantaxy/erotica", "ginipick/time-machine": "https://huggingface.co/spaces/ginipick/time-machine", "aiqcamp/FLUX-VisionReply": "https://huggingface.co/spaces/aiqcamp/FLUX-VisionReply", "openfree/Tetris-Game": "https://huggingface.co/spaces/openfree/Tetris-Game", "openfree/everychat": "https://huggingface.co/spaces/openfree/everychat", "VIDraft/mouse1": "https://huggingface.co/spaces/VIDraft/mouse1", "kolaslab/alpha-go": "https://huggingface.co/spaces/kolaslab/alpha-go", "ginipick/text3d": "https://huggingface.co/spaces/ginipick/text3d", "openfree/trending-board": "https://huggingface.co/spaces/openfree/trending-board", "cutechicken/tankwar": "https://huggingface.co/spaces/cutechicken/tankwar", "openfree/game-jewel": "https://huggingface.co/spaces/openfree/game-jewel", "VIDraft/mouse-chat": "https://huggingface.co/spaces/VIDraft/mouse-chat", "ginipick/AccDiffusion": "https://huggingface.co/spaces/ginipick/AccDiffusion", "aiqtech/Particle-Accelerator-Simulation": "https://huggingface.co/spaces/aiqtech/Particle-Accelerator-Simulation", "openfree/GiniGEN": "https://huggingface.co/spaces/openfree/GiniGEN", "kolaslab/3DAudio-Spectrum-Analyzer": "https://huggingface.co/spaces/kolaslab/3DAudio-Spectrum-Analyzer", "openfree/trending-news-24": "https://huggingface.co/spaces/openfree/trending-news-24", "ginipick/Realtime-FLUX": "https://huggingface.co/spaces/ginipick/Realtime-FLUX", "VIDraft/prime-number": "https://huggingface.co/spaces/VIDraft/prime-number", "kolaslab/zombie-game": "https://huggingface.co/spaces/kolaslab/zombie-game", "fantos/miro-game": "https://huggingface.co/spaces/fantos/miro-game", "kolaslab/shooting": "https://huggingface.co/spaces/kolaslab/shooting", "VIDraft/Mouse-Hackathon": "https://huggingface.co/spaces/VIDraft/Mouse-Hackathon", "upstage/open-ko-llm-leaderboard": "https://huggingface.co/spaces/upstage/open-ko-llm-leaderboard", "LGAI-EXAONE/EXAONE-3.5-Instruct-Demo": "https://huggingface.co/spaces/LGAI-EXAONE/EXAONE-3.5-Instruct-Demo", "NCSOFT/VARCO_Arena": "https://huggingface.co/spaces/NCSOFT/VARCO_Arena" } def get_trending_spaces(date): url = f"https://huggingface.co/api/spaces/trending?date={date}&limit=300" response = requests.get(url) if response.status_code == 200: return response.json() return None def get_space_rank(spaces, space_id): for idx, space in enumerate(spaces, 1): if space.get('id', '') == space_id: return idx return None def fetch_and_analyze_data(): start_date = datetime(2023, 12, 1) end_date = datetime(2023, 12, 31) dates = [(start_date + timedelta(days=x)).strftime('%Y-%m-%d') for x in range((end_date - start_date).days + 1)] trending_data = {} target_space_ranks = {space: [] for space in target_spaces.keys()} for date in dates: spaces = get_trending_spaces(date) if spaces: trending_data[date] = spaces for space_id in target_spaces.keys(): rank = get_space_rank(spaces, space_id) target_space_ranks[space_id].append(rank) return trending_data, target_space_ranks, dates def create_trend_plot(trending_data, target_space_ranks, dates): fig = go.Figure() for space_id, ranks in target_space_ranks.items(): fig.add_trace(go.Scatter( x=dates, y=ranks, name=space_id, mode='lines+markers' )) fig.update_layout( title='Trending Ranks Over Time', xaxis_title='Date', yaxis_title='Rank', yaxis_autorange='reversed', height=800 ) return fig def create_space_info_html(trending_data): latest_date = max(trending_data.keys()) latest_spaces = trending_data[latest_date] html_content = "
👍 Likes: {space_info.get('likes', 'N/A')}
📝 {space_info.get('title', 'N/A')}
{space_info.get('description', 'N/A')[:100]}...
Visit Space 🔗