dodoyy commited on
Commit
2c4e9e0
·
verified ·
1 Parent(s): c3e84b2

Restore the pre-Arrow Motion SVG interface

Browse files
Files changed (1) hide show
  1. app.py +4 -29
app.py CHANGED
@@ -6,7 +6,6 @@ import gradio as gr
6
 
7
  from generator import GenerationError, generate_svg
8
  from motion import edit_motion
9
- from quiver import ARROW_MODEL, QuiverError
10
  from validator import MAX_SVG_BYTES, SVGError
11
 
12
  HERE = Path(__file__).resolve().parent
@@ -34,15 +33,11 @@ def render_preview(svg: str) -> str:
34
  )
35
 
36
 
37
- def generate(
38
- prompt: str, upload: bytes | None, speed: float, repeat: str, color: str,
39
- model: str = "qwen", api_key: str | None = None,
40
- ):
41
- quiver_key = (api_key or "") if model == ARROW_MODEL else None
42
  try:
43
- source = generate_svg(prompt, upload, quiver_key=quiver_key)
44
  svg = edit_motion(source, speed, repeat, color)
45
- except (GenerationError, QuiverError, SVGError) as exc:
46
  raise gr.Error(str(exc)) from exc
47
  return source, render_preview(svg), svg
48
 
@@ -80,21 +75,6 @@ with gr.Blocks(title="Motion SVG", analytics_enabled=False, delete_cache=(1800,
80
  max_lines=5,
81
  max_length=600,
82
  )
83
- model = gr.Radio(
84
- choices=[("Quiver Arrow 2", ARROW_MODEL), ("Qwen · ZeroGPU", "qwen")],
85
- value=ARROW_MODEL,
86
- label="생성 모델",
87
- interactive=True,
88
- )
89
- api_key = gr.Textbox(
90
- label="Quiver API 키",
91
- value="",
92
- type="password",
93
- lines=1,
94
- max_length=512,
95
- info="프롬프트와 SVG는 Quiver로 전송돼요. 사용량은 키를 발급한 계정에 청구돼요. "
96
- "[API 키 만들기](https://platform.quiver.ai/api-keys)",
97
- )
98
  with gr.Accordion("기존 SVG에 움직임 추가", open=False):
99
  upload = gr.File(label="SVG 파일", file_types=[".svg"], type="binary", height=110)
100
  with gr.Row(elem_classes="input-actions"):
@@ -177,13 +157,8 @@ with gr.Blocks(title="Motion SVG", analytics_enabled=False, delete_cache=(1800,
177
 
178
  render_inputs = [speed, repeat, color]
179
  action_options = {"api_visibility": "private", "concurrency_id": "motion-workspace"}
180
- model.change(
181
- lambda selected: gr.update(visible=selected == ARROW_MODEL, value=""),
182
- model, api_key, queue=False, show_progress="hidden", api_visibility="private",
183
- )
184
  generate_btn.click(
185
- generate, [prompt, upload, *render_inputs, model, api_key],
186
- [source, preview, code], **action_options,
187
  )
188
  sample_btn.click(
189
  load_sample, outputs=[prompt, upload, *render_inputs, source, preview, code], **action_options,
 
6
 
7
  from generator import GenerationError, generate_svg
8
  from motion import edit_motion
 
9
  from validator import MAX_SVG_BYTES, SVGError
10
 
11
  HERE = Path(__file__).resolve().parent
 
33
  )
34
 
35
 
36
+ def generate(prompt: str, upload: bytes | None, speed: float, repeat: str, color: str):
 
 
 
 
37
  try:
38
+ source = generate_svg(prompt, upload)
39
  svg = edit_motion(source, speed, repeat, color)
40
+ except (GenerationError, SVGError) as exc:
41
  raise gr.Error(str(exc)) from exc
42
  return source, render_preview(svg), svg
43
 
 
75
  max_lines=5,
76
  max_length=600,
77
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  with gr.Accordion("기존 SVG에 움직임 추가", open=False):
79
  upload = gr.File(label="SVG 파일", file_types=[".svg"], type="binary", height=110)
80
  with gr.Row(elem_classes="input-actions"):
 
157
 
158
  render_inputs = [speed, repeat, color]
159
  action_options = {"api_visibility": "private", "concurrency_id": "motion-workspace"}
 
 
 
 
160
  generate_btn.click(
161
+ generate, [prompt, upload, *render_inputs], [source, preview, code], **action_options,
 
162
  )
163
  sample_btn.click(
164
  load_sample, outputs=[prompt, upload, *render_inputs, source, preview, code], **action_options,