Spaces:
Running
Running
| import aiohttp.web, asyncio, urllib.parse, pathlib, numpy, io, sys, math, os, uvloop, av, PIL.Image, itertools, builtins, huggingface_hub, time, traceback, modelscope, json | |
| prompts = ['her left hand finger grabing her left nipple, her boobs and cleavage are visible, breast bouncing, her right hand fingers spreading her vagina, spreading legs, buttocks jiggle', | |
| 'her right hand finger grabing her right nipple, her boobs and cleavage are visible, breast bouncing, left hand fingers spreading vagina, spreading legs, buttocks jiggle', | |
| 'camera slowly zooms in close-up shot to her orgasm face, thick strands of saliva stretching from her extended tongue, bright studio lighting, soft glow, no shadows on face', | |
| 'camera slowly tilts down close-up shot to her cleavage robust boob, breast bouncing', | |
| 'camera slowly tilts down close-up shot to her navel, wide side-to-side hip swaying, pronounced rhythmic pelvic motion', | |
| 'camera slowly tilts down close-up shot to her anus and vagina, transparent female ejaculation, spreading legs', | |
| 'camera slowly tilts down close-up shot to her thighs and feets, her anus and vagina are visible, spreading legs', | |
| 'camera slowly pulls back to reveal her full body lying on white bed, her vagina is visible, spreading legs', | |
| 'top-down, aerial view of she lying on her left side', | |
| 'camera from behind, she is lying on stomach with her upper body flat on bed and hip raised high, her hip moves up and down, her anus and vagina are visible, she is looking back over her shoulder with her mouth open, spreading legs', | |
| 'camera from behind, she is lying on stomach, camera rapidly zoom in close-up shot to her anus and vagina, her hip moves up and down', | |
| 'camera from behind, she is lying on stomach, camera slowly pulls back to reveal her full body, her hip moves up and down', | |
| 'she is lying on her right side, side profile view of her face with her left cheek against the pillow, her shoulders are stacked and vertically aligned with her hips, and her chest is oriented perpendicular to the bed, her left hand finger grabing her left nipple, her boobs and cleavage are visible, breast bouncing, her right hand fingers spreading her vagina, her left leg lift up, camera side view profile', | |
| 'she is lying on her right side, side profile view of her face with her left cheek against the pillow, Her shoulders are stacked and vertically aligned with her hips, and her chest is oriented perpendicular to the bed, her right hand finger grabing her right nipple, her boobs and cleavage are visible, breast bouncing, her left hand fingers spreading her vagina, her left leg lift up, camera side view profile', | |
| 'she is lying on her right side, side profile view of her face with her left cheek against the pillow, Her shoulders are stacked and vertically aligned with her hips, and her chest is oriented perpendicular to the bed, her right hand finger grabing her right nipple, her boobs and cleavage are visible, breast bouncing, her left hand fingers spreading her vagina, her left leg lift up, camera side view profile'] | |
| async def main(): | |
| app = aiohttp.web.Application() | |
| app.add_routes([aiohttp.web.static('/', pathlib.Path(__file__).resolve().parent, show_index=True)]) | |
| runner = aiohttp.web.AppRunner(app) | |
| await runner.setup() | |
| site = aiohttp.web.TCPSite(runner, port=7860) | |
| await site.start() | |
| async with aiohttp.ClientSession(headers={'authorization':'Bearer ' + os.getenv('modelscope')}, timeout=aiohttp.ClientTimeout()) as client: | |
| gorgeous = 'https://chaowenguo-gorgeous.ms.show/' | |
| async with client.post(urllib.parse.urljoin(gorgeous, 'imageStart'), json={'prompt':'a animation style naked full body front view gorgeous orgasm face slim young cleavage robust boob european mature woman lying on back on white bed, blond hair, spread eagle, arms spread wide, her boobs and cleavage are visible, spreading legs', 'height':720, 'width':1280}) as _:pass | |
| while True: | |
| async with client.get(urllib.parse.urljoin(gorgeous, 'imageGet')) as image: | |
| print(image.status) | |
| if image.status == 404: await asyncio.sleep(60) | |
| else: | |
| images = [await image.content.read()] | |
| with aiohttp.MultipartWriter('form-data') as mpwriter: | |
| mpwriter.append(json.dumps(prompts)).set_content_disposition('form-data', name='prompt') | |
| mpwriter.append(images[0], {'Content-Type':'image/png'}).set_content_disposition('form-data', name='image', filename='image.png') | |
| async with client.post(urllib.parse.urljoin(gorgeous, 'firstLastStart'), data=mpwriter) as _:pass | |
| while True: | |
| async with client.get(urllib.parse.urljoin(gorgeous, 'firstLastGet')) as firstLast: | |
| print(firstLast.status) | |
| if firstLast.status == 404: await asyncio.sleep(60) | |
| else: | |
| async for part in aiohttp.MultipartReader.from_response(firstLast): images += await part.read(), | |
| break | |
| with av.open('output.mp4', mode='w') as writer, av.open('output.wav') as container: | |
| video = writer.add_stream('h264', rate=8) | |
| image = PIL.Image.open(io.BytesIO(images[0])) | |
| video.height = image.size[1] | |
| video.width = image.size[0] | |
| video.pix_fmt = 'yuv420p' | |
| audio = writer.add_stream('aac', rate=48000) | |
| for prompt, (image, last) in builtins.zip(prompts, itertools.pairwise(images)): | |
| outer = False | |
| while True: | |
| with aiohttp.MultipartWriter('form-data') as mpwriter: | |
| mpwriter.append(prompt).set_content_disposition('form-data', name='prompt') | |
| mpwriter.append(image, {'Content-Type':'image/png'}).set_content_disposition('form-data', name='image', filename='image.png') | |
| mpwriter.append(last, {'Content-Type':'image/png'}).set_content_disposition('form-data', name='last', filename='last.png') | |
| async with client.post(urllib.parse.urljoin(gorgeous, 'videoStart'), data=mpwriter) as _: pass | |
| while True: | |
| try: | |
| async with client.get(urllib.parse.urljoin(gorgeous, 'videoGet')) as get: | |
| print(get.status) | |
| match get.status: | |
| case 404: await asyncio.sleep(60) | |
| case 500 | 429: break | |
| case 200: | |
| reader = numpy.load(io.BytesIO(await get.content.read())).get('arr_0') | |
| for frame in itertools.islice(reader, reader.shape[0] - 1): writer.mux(video.encode(av.VideoFrame.from_ndarray(frame))) | |
| outer = True | |
| break | |
| except (aiohttp.ClientConnectionError, aiohttp.ClientPayloadError): break | |
| if outer: break | |
| writer.mux(video.encode()) | |
| resampler = av.AudioResampler(format='fltp', layout='mono', rate=48000) | |
| audioPts = 0 | |
| for frame in container.decode(): | |
| for resample in resampler.resample(frame): | |
| resample.pts = audioPts | |
| audioPts += resample.samples | |
| writer.mux(audio.encode(resample)) | |
| writer.mux(audio.encode()) | |
| break | |
| modelscope.HubApi().upload_file(path_or_fileobj='output.mp4', path_in_repo='gorgeous.mp4', repo_id='chaowenguo/gorgeous', repo_type='dataset', token=os.getenv('modelscope')) | |
| await asyncio.sleep(math.inf) | |
| try: | |
| uvloop.run(main()) | |
| except: | |
| pathlib.Path(__file__).resolve().parent.joinpath('gorgeous.txt').write_text(traceback.format_exc()) | |
| huggingface_hub.upload_file(path_or_fileobj='gorgeous.txt', path_in_repo='gorgeous.txt', repo_id='exact-railcar/gorgeous', repo_type='dataset', token=os.getenv('huggingface')) | |
| time.sleep(math.inf) |