Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files8 unmodified lines910111213141516171819202122232428 unmodified lines5354555657589 unmodified lines6869707172737 unmodified lines818283848586878 unmodified linesimport jsonAPI_URL = "https://api-inference.huggingface.co/models/ovi054/rmx_flux"API_TOKEN = os.getenv("HF_READ_TOKEN")headers = {"Authorization": f"Bearer {API_TOKEN}"}timeout = 100def query(prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M Karras", seed=-1, strength=0.7):if prompt == "" or prompt == None:return Nonekey = random.randint(0, 999)API_TOKEN = random.choice([os.getenv("HF_READ_TOKEN")])headers = {"Authorization": f"Bearer {API_TOKEN}"}28 unmodified linesprint(f"Error when trying to open the image: {e}")return Nonecss = """#app-container {max-width: 600px;9 unmodified lineswith gr.Column(elem_id="prompt-container"):with gr.Row():text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")with gr.Row():with gr.Accordion("Advanced Settings", open=False):negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")7 unmodified linestext_button = gr.Button("Run", variant='primary', elem_id="gen-button")with gr.Row():image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)app.launch(show_api=False, share=False)8 unmodified lines91011121314151617181920212223242528 unmodified lines545556575859606162636465669 unmodified lines76777879808182837 unmodified lines9192939495969798991001011021031041058 unmodified linesimport jsonAPI_TOKEN = os.getenv("HF_READ_TOKEN")headers = {"Authorization": f"Bearer {API_TOKEN}"}timeout = 100def query(lora_id="ByteDance/Hyper-SD", prompt, is_negative=False, steps=28, cfg_scale=3.5, sampler="DPM++ 2M Karras", seed=-1, strength=0.7):if prompt == "" or prompt == None:return Nonekey = random.randint(0, 999)API_URL = "https://api-inference.huggingface.co/models/"+ lora_idAPI_TOKEN = random.choice([os.getenv("HF_READ_TOKEN")])headers = {"Authorization": f"Bearer {API_TOKEN}"}28 unmodified linesprint(f"Error when trying to open the image: {e}")return Noneexamples = ["a tiny astronaut hatching from an egg on the moon","a cat holding a sign that says hello world","an anime illustration of a wiener schnitzel",]css = """#app-container {max-width: 600px;9 unmodified lineswith gr.Column(elem_id="prompt-container"):with gr.Row():text_prompt = gr.Textbox(label="Prompt", placeholder="Enter a prompt here", lines=2, elem_id="prompt-text-input")with gr.Row():custom_lora = gr.Textbox(label="Custom LoRA", info="LoRA Hugging Face path", placeholder="multimodalart/vintage-ads-flux")with gr.Row():with gr.Accordion("Advanced Settings", open=False):negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="What should not be in the image", value="(deformed, distorted, disfigured), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, misspellings, typos", lines=3, elem_id="negative-prompt-text-input")7 unmodified linestext_button = gr.Button("Run", variant='primary', elem_id="gen-button")with gr.Row():image_output = gr.Image(type="pil", label="Image Output", elem_id="gallery")gr.Examples(examples = examples,fn = infer,inputs = [prompt],outputs = [result, seed],cache_examples="lazy")text_button.click(query, inputs=[custom_lora, text_prompt, negative_prompt, steps, cfg, method, seed, strength], outputs=image_output)app.launch(show_api=False, share=False)
app.py+21-3