jejunepixels commited on
Commit
9d07534
·
verified ·
1 Parent(s): 8884863

Update hub_ui.py

Browse files
Files changed (1) hide show
  1. hub_ui.py +28 -7
hub_ui.py CHANGED
@@ -4,14 +4,33 @@ from queue import Empty, Queue
4
 
5
  import streamlit as st
6
 
7
- from hub_models import build_plan, discover_models, download_model, format_size, friendly_hub_error
8
  from hub_models import CACHE_ROOT
9
  from app_environment import hosted_mode, hosted_download_limit, new_session_directory, PRIVATE_CACHE_ROOT
10
 
11
 
 
 
 
 
 
 
 
 
 
 
12
  def render_hub_loader(activate_model):
13
- st.caption('Paste a model repository ID or Hugging Face URL, then choose its weights.')
14
- repo = st.text_input('Hugging Face repository or URL', placeholder='owner/model or https://huggingface.co/owner/model', key='hf_repo')
 
 
 
 
 
 
 
 
 
15
  with st.expander('Revision & access token (optional)'):
16
  revision = st.text_input('Revision', placeholder='main, branch, tag or commit', key='hf_revision')
17
  token = st.text_input('Hugging Face read token', type='password', key='hf_token',
@@ -57,11 +76,13 @@ def render_hub_loader(activate_model):
57
  with st.expander('Files to download'):
58
  for filename in plan.files:
59
  st.text(f'{filename} · {format_size(catalog.files.get(filename))}')
60
- limit = hosted_download_limit()
61
- if limit is not None and (plan.size is None or plan.size > limit):
62
- st.info('This hosted Space supports downloads up to 4 GB with a known size. Choose smaller weights, upload embedding shards, or run the app locally for larger models.')
 
63
  return
64
- if st.button('Download & load', key='hf_download', type='primary', use_container_width=True):
 
65
  events = Queue()
66
  progress = st.progress(0, text='Preparing download…')
67
  try:
 
4
 
5
  import streamlit as st
6
 
7
+ from hub_models import build_plan, discover_models, download_model, format_size, friendly_hub_error, check_hosted_download
8
  from hub_models import CACHE_ROOT
9
  from app_environment import hosted_mode, hosted_download_limit, new_session_directory, PRIVATE_CACHE_ROOT
10
 
11
 
12
+ MODEL_PRESETS = {
13
+ 'SmolLM2 135M · small & quick': ('HuggingFaceTB/SmolLM2-135M', 'About 271 MB · English · safetensors'),
14
+ 'GPT-2 · classic English model': ('openai-community/gpt2', 'About 549 MB · English · safetensors'),
15
+ 'Gemma 3 1B · Q4 GGUF': (
16
+ 'https://huggingface.co/lmstudio-community/gemma-3-1B-it-qat-GGUF/blob/main/gemma-3-1B-it-QAT-Q4_0.gguf',
17
+ 'About 720 MB · quantized GGUF'),
18
+ 'Qwen3 0.6B · multilingual': ('Qwen/Qwen3-0.6B', 'About 1.52 GB · multilingual · safetensors'),
19
+ }
20
+
21
+
22
  def render_hub_loader(activate_model):
23
+ st.caption('Choose a suggested model or paste a Hugging Face link. Weights download directly to this Space.'
24
+ if hosted_mode() else 'Choose a suggested model or paste a Hugging Face link. Weights download to this computer.')
25
+ source = st.radio('Model source', ['Choose from list', 'Paste URL or repository ID'], horizontal=True, key='hf_source')
26
+ if source == 'Choose from list':
27
+ preset = st.selectbox('Suggested model', list(MODEL_PRESETS), key='hf_preset')
28
+ repo, description = MODEL_PRESETS[preset]
29
+ st.caption(description + ' · downloaded on first use; cached copies are reused')
30
+ else:
31
+ repo = st.text_input('Hugging Face repository or URL', placeholder='owner/model or https://huggingface.co/owner/model', key='hf_repo')
32
+ if hosted_mode():
33
+ st.caption(f'Up to {format_size(hosted_download_limit())} per model, subject to free storage. Larger vocabularies take longer to search.')
34
  with st.expander('Revision & access token (optional)'):
35
  revision = st.text_input('Revision', placeholder='main, branch, tag or commit', key='hf_revision')
36
  token = st.text_input('Hugging Face read token', type='password', key='hf_token',
 
76
  with st.expander('Files to download'):
77
  for filename in plan.files:
78
  st.text(f'{filename} · {format_size(catalog.files.get(filename))}')
79
+ try:
80
+ check_hosted_download(plan)
81
+ except (ValueError, OSError) as error:
82
+ st.info(str(error))
83
  return
84
+ load_label = 'Load into Space' if hosted_mode() else 'Download & load'
85
+ if st.button(load_label, key='hf_download', type='primary', use_container_width=True):
86
  events = Queue()
87
  progress = st.progress(0, text='Preparing download…')
88
  try: