Spaces:
Running
Running
Wave 20: pydraw master 9a02d6c with people and animal drawers on (portraits in every style, faces, full-body poses, contacts, animals and birds); style toggle removed, styles come from the prompt
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+9
- app.py+8-5
- pydraw/__init__.py+48-4
- pydraw/__pycache__/__init__.cpython-310.pycAdded
- pydraw/__pycache__/actions.cpython-310.pycAdded
- pydraw/__pycache__/atmos.cpython-310.pycAdded+3
- pydraw/__pycache__/attach.cpython-310.pycAdded
- pydraw/__pycache__/canvas.cpython-310.pycAdded
- pydraw/__pycache__/character2d.cpython-310.pycAdded
- pydraw/__pycache__/characters.cpython-310.pycAdded+3
- pydraw/__pycache__/colorcheck.cpython-310.pycAdded
- pydraw/__pycache__/compose.cpython-310.pycAdded
- pydraw/__pycache__/contact.cpython-310.pycAdded
- pydraw/__pycache__/craft.cpython-310.pycAdded
- pydraw/__pycache__/director.cpython-310.pycAdded
- pydraw/__pycache__/formlight.cpython-310.pycAdded
- pydraw/__pycache__/frames.cpython-310.pycAdded
- pydraw/__pycache__/gbuf.cpython-310.pycAdded
- pydraw/__pycache__/gloss.cpython-310.pycAdded
- pydraw/__pycache__/imagine.cpython-310.pycAdded
- pydraw/__pycache__/kit.cpython-310.pycAdded
- pydraw/__pycache__/language.cpython-310.pycAdded
- pydraw/__pycache__/layout.cpython-310.pycAdded
- pydraw/__pycache__/lexicon.cpython-310.pycAdded
- pydraw/__pycache__/materials.cpython-310.pycAdded
- pydraw/__pycache__/matpx.cpython-310.pycAdded
- pydraw/__pycache__/media_ink.cpython-310.pycAdded
- pydraw/__pycache__/media_paint.cpython-310.pycAdded
- pydraw/__pycache__/mood.cpython-310.pycAdded
- pydraw/__pycache__/nature.cpython-310.pycAdded
- pydraw/__pycache__/open_vocab.cpython-310.pycAdded
- pydraw/__pycache__/perch.cpython-310.pycAdded
- pydraw/__pycache__/physics.cpython-310.pycAdded
- pydraw/__pycache__/physics2.cpython-310.pycAdded
- pydraw/__pycache__/picplan.cpython-310.pycAdded
- pydraw/__pycache__/pixelart.cpython-310.pycAdded
- pydraw/__pycache__/pixelcraft.cpython-310.pycAdded
- pydraw/__pycache__/pixeltex.cpython-310.pycAdded
- pydraw/__pycache__/plan.cpython-310.pycAdded
- pydraw/__pycache__/planes.cpython-310.pycAdded
- pydraw/__pycache__/ramps.cpython-310.pycAdded
- pydraw/__pycache__/registry.cpython-310.pycAdded
- pydraw/__pycache__/retro.cpython-310.pycAdded
- pydraw/__pycache__/scenes.cpython-310.pycAdded+3
- pydraw/__pycache__/shading.cpython-310.pycAdded
- pydraw/__pycache__/skies.cpython-310.pycAdded
- pydraw/__pycache__/stage.cpython-310.pycAdded
- pydraw/__pycache__/stilllife.cpython-310.pycAdded+3
- pydraw/__pycache__/styles.cpython-310.pycAdded
- pydraw/__pycache__/surface.cpython-310.pycAdded
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines33343536373839404142434432 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textpydraw/__pycache__/atmos.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw/__pycache__/characters.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw/__pycache__/scenes.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw/__pycache__/stilllife.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw/__pycache__/world.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw/concepts/__pycache__/objects4.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw/concepts/__pycache__/people.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw3d/families/__pycache__/food.cpython-310.pyc filter=lfs diff=lfs merge=lfs -textpydraw3d/families/__pycache__/objects.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
2 unmodified lines345678910192 unmodified lines20320420520620720855 unmodified lines2642652662672682692702712722732742752762772782 unmodified linesimport 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 wordnet192 unmodified lines.pd-about b { color:var(--pd-ink); }/* footer line (PyBot) */#pd-foot { margin:14px 0 0; font:13px/1.5 var(--pd-mono); color:var(--pd-muted); overflow-wrap:anywhere; }#pd-foot a { color:inherit; text-underline-offset:2px; }55 unmodified linesgr.Markdown("Describe a picture", elem_classes="pd-kicker")prompt = gr.Textbox(value=EXAMPLES[0], lines=2, max_lines=6, show_label=False, container=False,placeholder="a fox in a cape next to a waving flag", elem_id="pd-prompt")with gr.Column(elem_classes="pd-card"):style = gr.Radio(RENDERERS, value="pixel", label="Renderer", elem_id="pd-renderer")with gr.Row():seed = gr.Number(label="Seed", value=0, precision=0, min_width=120)size = gr.Dropdown([512, 768], value=512, label="Size", min_width=120)variation = gr.Slider(0, 1, value=1, step=0.25, label="Variation",info="Varies only what the prompt leaves open (breed, colour of unnamed things, time, setting, framing). 0 = canonical image.")search = gr.Checkbox(False, label="Search (3D only, several times slower)",info="Renders cheap previews of different scene layouts, scores them with hand-written rules and keeps the best.")with gr.Row(elem_id="pd-actions"):btn = gr.Button("Draw", variant="primary", elem_id="pd-draw")btn4 = gr.Button("4 variations", elem_id="pd-draw4")2 unmodified lines34567891011192 unmodified lines20420520620720820921055 unmodified lines2662672682692702712722732742752762772782792802812 unmodified linesimport timeimport nltk# wave 20 people and animals: 2D-first portraits in every style (fig2d), faces (expressions, age, costume), paint and# ink portrait styles, full-body poses, contacts, and the new animal and bird drawersos.environ.setdefault("PYDRAW_EXP", "fig2d=1,fx_face=1,st_paint=1,st_ink=1,body2d=1,cx=1,c2d=1")try:from nltk.corpus import wordnet192 unmodified lines.pd-about b { color:var(--pd-ink); }/* footer line (PyBot) */#pd-hint { font:13px/1.5 var(--pd-mono); color:var(--pd-muted); margin:-4px 0 4px; }#pd-foot { margin:14px 0 0; font:13px/1.5 var(--pd-mono); color:var(--pd-muted); overflow-wrap:anywhere; }#pd-foot a { color:inherit; text-underline-offset:2px; }55 unmodified linesgr.Markdown("Describe a picture", elem_classes="pd-kicker")prompt = gr.Textbox(value=EXAMPLES[0], lines=2, max_lines=6, show_label=False, container=False,placeholder="a fox in a cape next to a waving flag", elem_id="pd-prompt")gr.Markdown("Name a style in the prompt (watercolor, oil painting, ink and wash, linocut, pencil, anime). With no style word you get pixel art.",elem_id="pd-hint")style = gr.State("pixel")search = gr.State(False)with gr.Column(elem_classes="pd-card"):with gr.Row():seed = gr.Number(label="Seed", value=0, precision=0, min_width=120)size = gr.Dropdown([512, 768], value=512, label="Size", min_width=120)variation = gr.Slider(0, 1, value=1, step=0.25, label="Variation",info="Varies only what the prompt leaves open (breed, colour of unnamed things, time, setting, framing). 0 = canonical image.")with gr.Row(elem_id="pd-actions"):btn = gr.Button("Draw", variant="primary", elem_id="pd-draw")btn4 = gr.Button("4 variations", elem_id="pd-draw4")
38 unmodified lines3940414243444 unmodified lines4950515253546 unmodified lines61626364656667686942 unmodified lines1121131141151161171181191201211222 unmodified lines1251261271281291301314 unmodified lines13613713813914014114214314414514638 unmodified linesfrom .figure import try_portrait as _fig_portrait_fig = _fig_portrait(text, scene, seed, size, style, trace)if _fig is not None:return _fig# wave 15 (gbuf): a medium renderer registered for the style word paints from the G-buffer (pydraw/gbuf.py;# knob media=0 / media_<name>=0 keeps the old styles.py filter)4 unmodified linesreturn _render(text, scene, rng, pstyle, trace, seed, size, style, res)def prepare(text, seed, variation, trace):"""parse + vary + mood + style rules + the director's pre-pass: the scene every renderer draws (plot, gbuffer)"""rng = random.Random(seed)6 unmodified lines# the prompt, so different prompts at the same seed don't all get the same noon meadow (critic3 round 17)import zlib as _zlib_vseed += _zlib.crc32(" ".join(text.lower().split()).encode()) % 100003vary(scene, trace, random.Random(_vseed), float(_ev.get("vary", variation)), light=True)from . import mood as _mood_mood.apply(scene, text, trace) # wave 12: visual rhetoric (mood words -> time, weather, camera, framing, grade)pstyle = scene.get("style")if pstyle == "abstract":import re as _re42 unmodified linespixels = pixelart.upscale(px, max(1, size // _R))else:pixels = styles.upscale_bilinear(px, size) if _R != size else pxreturn Image(pixels, scene, trace)if renderer == "pixel":# rule: draw at half the output size (512 -> 256): more detail scored better on every benchmark than 128R = res or int(EXP.get("res", size // 2 if size >= 256 else size))insts, y0 = layout(scene, R, R, rng, trace)if scene.get("abstract_comp"):# rule: abstract shapes float and overlap across the whole frame at varied sizesfor it in insts:2 unmodified linesit.x = R * rng.uniform(.2, .8)it.y = R * rng.uniform(.4, .95)it.pose, it.bound, it.rel = "flying", None, Nonecv, outline_ids = compose(scene, insts, y0, R, R, rng, trace, ss=1)pixelart.finish(cv, outline_ids if EXP.get("outline", "1") == "1" else set(), trace, dither=float(EXP.get("dither", 12.0)))if getattr(cv, "glyphs", None): # wave 16 (glyphs): face / hand symbols written on the finished gridfrom .rig.glyphs import restamp as _gly_restamp4 unmodified linesstyles.apply(pstyle, cv.px, seed, trace) # rule: tone styles run after the palette snap so it can't undo themframes.apply_px(scene, cv.px, trace) # language shift 2: "a postcard of X"pixels = pixelart.upscale(cv.px, max(1, size // R))else:R = res or max(128, size // 2)insts, y0 = layout(scene, R, R, rng, trace)cv, _ = compose(scene, insts, y0, R, R, rng, trace, ss=2)styles.apply(pstyle, cv.px, seed, trace, ids=cv.ids)frames.apply_px(scene, cv.px, trace)pixels = styles.upscale_bilinear(cv.px, size) if R != size else cv.pxreturn Image(pixels, scene, trace)38 unmodified lines394041424344454 unmodified lines505152535455565758596061626364656667686970717273746 unmodified lines8182838485868788899091929342 unmodified lines1361371381391401411421431441451461471481491502 unmodified lines1531541551561571581591601611621631644 unmodified lines16917017117217317417517617717817918018118218318418518618718818919038 unmodified linesfrom .figure import try_portrait as _fig_portrait_fig = _fig_portrait(text, scene, seed, size, style, trace)if _fig is not None:_claim(_fig, scene, "figure", seed, size)return _fig# wave 15 (gbuf): a medium renderer registered for the style word paints from the G-buffer (pydraw/gbuf.py;# knob media=0 / media_<name>=0 keeps the old styles.py filter)4 unmodified linesreturn _render(text, scene, rng, pstyle, trace, seed, size, style, res)def _claim(img, scene, renderer, seed, size, cv=None, ids=None, inst=None, y0=None, sun=None):"""wave 19 (plan): the claim record (subject, objects, depth layers, emitters, light key) on the Image; Image.savewrites it as <out>.claim.json when PYDRAW_CLAIM=1 (pydraw/picplan.py)"""from . import picplan as _ppif not _pp.claim_level():return imgtry:if cv is not None:ids, inst, y0, sun = cv.ids, getattr(cv, "id_inst", None), getattr(cv, "y0", None), getattr(cv, "sun", None)rec = _pp.claim(scene, renderer, ids=ids, inst=inst, y0=y0, sun=sun, size=size, seed=seed,key=getattr(cv, "pp_key", None) if cv is not None else None)if ids is not None:rec["_ids"] = idsimg.claim = recexcept Exception as ex: # a report must never take the picture downimg.trace.append("picplan: claim failed (%s)" % str(ex)[:80])return imgdef prepare(text, seed, variation, trace):"""parse + vary + mood + style rules + the director's pre-pass: the scene every renderer draws (plot, gbuffer)"""rng = random.Random(seed)6 unmodified lines# the prompt, so different prompts at the same seed don't all get the same noon meadow (critic3 round 17)import zlib as _zlib_vseed += _zlib.crc32(" ".join(text.lower().split()).encode()) % 100003_parsed = (scene.get("time"), scene.get("weather"))vary(scene, trace, random.Random(_vseed), float(_ev.get("vary", variation)), light=True)from . import picplan as _pp # wave 19 (plan, pp_key): the variation layer may not invent a time of day_pp.hold_time(scene, trace, _parsed)from . import mood as _mood_mood.apply(scene, text, trace) # wave 12: visual rhetoric (mood words -> time, weather, camera, framing, grade)_pp.expose_key(scene) # wave 19 (plan, pp_key): scene["_light_key"] for the thumbnail search (pydraw/thumbs.py)pstyle = scene.get("style")if pstyle == "abstract":import re as _re42 unmodified linespixels = pixelart.upscale(px, max(1, size // _R))else:pixels = styles.upscale_bilinear(px, size) if _R != size else pxreturn _claim(Image(pixels, scene, trace), scene, "still", seed, size)if renderer == "pixel":# rule: draw at half the output size (512 -> 256): more detail scored better on every benchmark than 128R = res or int(EXP.get("res", size // 2 if size >= 256 else size))insts, y0 = layout(scene, R, R, rng, trace)from . import picplan as _pp, canvas as _cvmod # wave 19 (plan): layer tags for the plan / claim_cap = _pp.any_on() and not _cvmod.CAPTURE[0]if _cap:_cvmod.CAPTURE[0] = Trueif scene.get("abstract_comp"):# rule: abstract shapes float and overlap across the whole frame at varied sizesfor it in insts:2 unmodified linesit.x = R * rng.uniform(.2, .8)it.y = R * rng.uniform(.4, .95)it.pose, it.bound, it.rel = "flying", None, Nonetry:cv, outline_ids = compose(scene, insts, y0, R, R, rng, trace, ss=1)finally:if _cap:_cvmod.CAPTURE[0] = False_pp.run_canvas(cv, scene, trace) # wave 19 (plan): the picture's value plan before the palette snappixelart.finish(cv, outline_ids if EXP.get("outline", "1") == "1" else set(), trace, dither=float(EXP.get("dither", 12.0)))if getattr(cv, "glyphs", None): # wave 16 (glyphs): face / hand symbols written on the finished gridfrom .rig.glyphs import restamp as _gly_restamp4 unmodified linesstyles.apply(pstyle, cv.px, seed, trace) # rule: tone styles run after the palette snap so it can't undo themframes.apply_px(scene, cv.px, trace) # language shift 2: "a postcard of X"pixels = pixelart.upscale(cv.px, max(1, size // R))renderer = "pixel"else:R = res or max(128, size // 2)insts, y0 = layout(scene, R, R, rng, trace)from . import picplan as _pp, canvas as _cvmod_cap = _pp.any_on() and not _cvmod.CAPTURE[0]if _cap:_cvmod.CAPTURE[0] = Truetry:cv, _ = compose(scene, insts, y0, R, R, rng, trace, ss=2)finally:if _cap:_cvmod.CAPTURE[0] = False_pp.run_canvas(cv, scene, trace) # wave 19 (plan): the value plan before the style filterstyles.apply(pstyle, cv.px, seed, trace, ids=cv.ids)frames.apply_px(scene, cv.px, trace)pixels = styles.upscale_bilinear(cv.px, size) if R != size else cv.pxrenderer = "smooth"return _claim(Image(pixels, scene, trace), scene, renderer, seed, size, cv=cv)
123version https://git-lfs.github.com/spec/v1oid sha256:8facd91510a0cb26266cdc7aceba1e054c9599c158605e678438c5bad37a9453size 100391123version https://git-lfs.github.com/spec/v1oid sha256:250414d8a0889b8e8102d8af775ae818681a6e73610ca411ccf7652dbb0c9710size 104397123version https://git-lfs.github.com/spec/v1oid sha256:14b7c8d8e1f69e26344ea4ec314754142df58de5a3257f2b81565b15afb919aesize 144434123version https://git-lfs.github.com/spec/v1oid sha256:f7af37ca6fc6d10abe1858255f46da6fc0bd9648de6a107bfa7018c1759429a0size 107241.gitattributes+9
app.py+8-5
pydraw/__init__.py+48-4
pydraw/__pycache__/__init__.cpython-310.pycAdded
pydraw/__pycache__/actions.cpython-310.pycAdded
pydraw/__pycache__/atmos.cpython-310.pycAdded+3
pydraw/__pycache__/attach.cpython-310.pycAdded
pydraw/__pycache__/canvas.cpython-310.pycAdded
pydraw/__pycache__/character2d.cpython-310.pycAdded
pydraw/__pycache__/characters.cpython-310.pycAdded+3
pydraw/__pycache__/colorcheck.cpython-310.pycAdded
pydraw/__pycache__/compose.cpython-310.pycAdded
pydraw/__pycache__/contact.cpython-310.pycAdded
pydraw/__pycache__/craft.cpython-310.pycAdded
pydraw/__pycache__/director.cpython-310.pycAdded
pydraw/__pycache__/formlight.cpython-310.pycAdded
pydraw/__pycache__/frames.cpython-310.pycAdded
pydraw/__pycache__/gbuf.cpython-310.pycAdded
pydraw/__pycache__/gloss.cpython-310.pycAdded
pydraw/__pycache__/imagine.cpython-310.pycAdded
pydraw/__pycache__/kit.cpython-310.pycAdded
pydraw/__pycache__/language.cpython-310.pycAdded
pydraw/__pycache__/layout.cpython-310.pycAdded
pydraw/__pycache__/lexicon.cpython-310.pycAdded
pydraw/__pycache__/materials.cpython-310.pycAdded
pydraw/__pycache__/matpx.cpython-310.pycAdded
pydraw/__pycache__/media_ink.cpython-310.pycAdded
pydraw/__pycache__/media_paint.cpython-310.pycAdded
pydraw/__pycache__/mood.cpython-310.pycAdded
pydraw/__pycache__/nature.cpython-310.pycAdded
pydraw/__pycache__/open_vocab.cpython-310.pycAdded
pydraw/__pycache__/perch.cpython-310.pycAdded
pydraw/__pycache__/physics.cpython-310.pycAdded
pydraw/__pycache__/physics2.cpython-310.pycAdded
pydraw/__pycache__/picplan.cpython-310.pycAdded
pydraw/__pycache__/pixelart.cpython-310.pycAdded
pydraw/__pycache__/pixelcraft.cpython-310.pycAdded
pydraw/__pycache__/pixeltex.cpython-310.pycAdded
pydraw/__pycache__/plan.cpython-310.pycAdded
pydraw/__pycache__/planes.cpython-310.pycAdded
pydraw/__pycache__/ramps.cpython-310.pycAdded
pydraw/__pycache__/registry.cpython-310.pycAdded
pydraw/__pycache__/retro.cpython-310.pycAdded
pydraw/__pycache__/scenes.cpython-310.pycAdded+3
pydraw/__pycache__/shading.cpython-310.pycAdded
pydraw/__pycache__/skies.cpython-310.pycAdded
pydraw/__pycache__/stage.cpython-310.pycAdded
pydraw/__pycache__/stilllife.cpython-310.pycAdded+3
pydraw/__pycache__/styles.cpython-310.pycAdded
pydraw/__pycache__/surface.cpython-310.pycAdded