Spaces:
Running
Running
Anime portraits via the 2D-first portrait path, neutral grey palette with orange accent, six varied examples
Browse files12345677 unmodified lines151617181920212223242550 unmodified lines7677787980818283848586878889909192939471 unmodified lines16616716816917017117275 unmodified lines248249250251252253254255256"""PyDraw playground: rule-only text to image (no weights, no training, no image files)."""import timeimport nltktry:from nltk.corpus import wordnetwordnet.synsets("dog")7 unmodified linesfrom pydraw3d import plot3dfrom pydraw3d.families import FAMILIES, TAXAEXAMPLES = ["a watercolor painting of a bowl of fruit", "an ink and wash drawing of a boat on a lake","a linocut print of a cabin in the woods", "a lonely lighthouse at night with lightning","a castle on a hill with a dragon flying above it at sunset", "a mountain lake with pine trees","a red barn in a field of sunflowers", "a cozy cabin in a snowy forest at night","a teapot and two cups on a table", "three yellow ducks swimming on a lake"]RENDERERS = ["pixel", "3D", "smooth"]GITHUB = "https://github.com/linoytsaban/pydraw"50 unmodified linesCSS = """:root, .gradio-container {--pd-bg:#eef1ec; --pd-surface:#fbfdf9; --pd-ink:#18201b; --pd-muted:#68736c; --pd-faint:#aab4ad; --pd-line:#dfe5df;--pd-accent:#0b7f63; --pd-accent-btn:#10a37f; --pd-accent-soft:rgb(16 163 127 / .15); --pd-on-accent:#fff; --pd-hot:#eb6834;--pd-check-a:#e3e8e3; --pd-check-b:#f4f7f3;--pd-shadow:0 1px 2px rgb(24 32 27 / .05), 0 10px 30px rgb(24 32 27 / .07);--pd-hero-shadow:0 30px 80px rgb(24 32 27 / .16);--pd-serif:"Fraunces", Georgia, "Times New Roman", serif;--pd-pixel:"Pixelify Sans", ui-monospace, monospace;--pd-mono:"IBM Plex Mono", ui-monospace, Menlo, monospace;}.dark, .dark .gradio-container {--pd-bg:#0f1311; --pd-surface:#1a201c; --pd-ink:#edf3ee; --pd-muted:#95a199; --pd-faint:#4d5850; --pd-line:#28302b;--pd-accent:#5eead4; --pd-accent-btn:#5eead4; --pd-accent-soft:rgb(94 234 212 / .18); --pd-on-accent:#0f1311;--pd-check-a:#1d2420; --pd-check-b:#252d28;--pd-shadow:0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);--pd-hero-shadow:0 30px 80px rgb(0 0 0 / .55);}71 unmodified lines#pd-hero .image-container, #pd-hero .image-frame, #pd-hero > div { background:transparent !important; height:100% !important; }#pd-hero img { image-rendering:pixelated; image-rendering:crisp-edges; width:100%; height:100%; object-fit:contain; }#pd-hero .empty, #pd-hero [class*="empty"] { font:300 clamp(20px,2.2vw,28px)/1.2 var(--pd-serif); color:var(--pd-muted); }#pd-hero label[data-testid="block-label"], #pd-hero .block-label { background:rgb(255 255 255 / .9) !important; color:#18201b !important; border-radius:999px !important;border:0 !important; font:500 12px var(--pd-pixel) !important; letter-spacing:.06em; text-transform:uppercase; margin:10px; }/* the answer: PyBot's mono "why" line under the picture */75 unmodified linesFOOT = ("<p id='pd-foot'>PyDraw is plain Python: a parser, a layout engine, drawing rules and a ray-marcher, no weights, no training, no image files. ""Code: <a href='%s' target='_blank' rel='noopener noreferrer'>github.com/linoytsaban/pydraw</a>.</p>" % GITHUB)THEME = gr.themes.Base(primary_hue="emerald", neutral_hue="stone", radius_size="lg").set(slider_color="#10a37f", slider_color_dark="#5eead4", checkbox_background_color_selected="#10a37f",checkbox_background_color_selected_dark="#5eead4", color_accent="#10a37f", color_accent_soft="rgba(16,163,127,.15)")with gr.Blocks(title="PyDraw") as demo:gr.HTML(HEADER)12345678910117 unmodified lines19202122232425262728293050 unmodified lines8182838485868788899091929394959697989971 unmodified lines17117217317417517617775 unmodified lines253254255256257258259260261"""PyDraw playground: rule-only text to image (no weights, no training, no image files)."""import osimport timeimport nltk# anime portraits use the 2D-first portrait path (wave 18); other styles keep the default path for nowos.environ.setdefault("PYDRAW_EXP", "fig2d=1,fig2d_pixel=0,fig2d_ink=0,fig2d_paint=0")try:from nltk.corpus import wordnetwordnet.synsets("dog")7 unmodified linesfrom pydraw3d import plot3dfrom pydraw3d.families import FAMILIES, TAXAEXAMPLES = ["a watercolor painting of a bowl of fruit","anime portrait of a girl with long blue hair","a castle on a hill with a dragon flying above it at sunset","a linocut print of a cabin in the woods","a bear holding a mug that says HUG","an ink and wash drawing of a boat on a lake"]RENDERERS = ["pixel", "3D", "smooth"]GITHUB = "https://github.com/linoytsaban/pydraw"50 unmodified linesCSS = """:root, .gradio-container {--pd-bg:#f4f4f3; --pd-surface:#ffffff; --pd-ink:#1a1a1a; --pd-muted:#6b6b6b; --pd-faint:#b3b3b3; --pd-line:#e3e3e1;--pd-accent:#c2410c; --pd-accent-btn:#ea580c; --pd-accent-soft:rgb(234 88 12 / .12); --pd-on-accent:#fff; --pd-hot:#ea580c;--pd-check-a:#e9e9e7; --pd-check-b:#f6f6f5;--pd-shadow:0 1px 2px rgb(0 0 0 / .05), 0 10px 30px rgb(0 0 0 / .07);--pd-hero-shadow:0 30px 80px rgb(0 0 0 / .16);--pd-serif:"Fraunces", Georgia, "Times New Roman", serif;--pd-pixel:"Pixelify Sans", ui-monospace, monospace;--pd-mono:"IBM Plex Mono", ui-monospace, Menlo, monospace;}.dark, .dark .gradio-container {--pd-bg:#121212; --pd-surface:#1c1c1c; --pd-ink:#f0f0f0; --pd-muted:#a3a3a3; --pd-faint:#555555; --pd-line:#2b2b2b;--pd-accent:#fb923c; --pd-accent-btn:#fb923c; --pd-accent-soft:rgb(251 146 60 / .16); --pd-on-accent:#121212;--pd-check-a:#1f1f1f; --pd-check-b:#272727;--pd-shadow:0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);--pd-hero-shadow:0 30px 80px rgb(0 0 0 / .55);}71 unmodified lines#pd-hero .image-container, #pd-hero .image-frame, #pd-hero > div { background:transparent !important; height:100% !important; }#pd-hero img { image-rendering:pixelated; image-rendering:crisp-edges; width:100%; height:100%; object-fit:contain; }#pd-hero .empty, #pd-hero [class*="empty"] { font:300 clamp(20px,2.2vw,28px)/1.2 var(--pd-serif); color:var(--pd-muted); }#pd-hero label[data-testid="block-label"], #pd-hero .block-label { background:rgb(255 255 255 / .9) !important; color:#1a1a1a !important; border-radius:999px !important;border:0 !important; font:500 12px var(--pd-pixel) !important; letter-spacing:.06em; text-transform:uppercase; margin:10px; }/* the answer: PyBot's mono "why" line under the picture */75 unmodified linesFOOT = ("<p id='pd-foot'>PyDraw is plain Python: a parser, a layout engine, drawing rules and a ray-marcher, no weights, no training, no image files. ""Code: <a href='%s' target='_blank' rel='noopener noreferrer'>github.com/linoytsaban/pydraw</a>.</p>" % GITHUB)THEME = gr.themes.Base(primary_hue="orange", neutral_hue="neutral", radius_size="lg").set(slider_color="#ea580c", slider_color_dark="#fb923c", checkbox_background_color_selected="#ea580c",checkbox_background_color_selected_dark="#fb923c", color_accent="#ea580c", color_accent_soft="rgba(234,88,12,.12)")with gr.Blocks(title="PyDraw") as demo:gr.HTML(HEADER)
app.py+22-17