xpvwklvjp commited on
Commit
dde0025
Β·
verified Β·
1 Parent(s): abd3046

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -6
app.py CHANGED
@@ -1,11 +1,53 @@
1
  import gradio as gr
2
- import time
3
- import logging
 
4
 
5
- # Set up logging
6
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
7
- logger = logging.getLogger(__name__)
 
 
 
 
 
 
 
 
 
8
 
9
- demo = gr.load("models/John6666/the-araminta-fv1-sdxl")
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  demo.launch()
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import DiffusionPipeline
4
+ import os
5
 
6
+ # Ensure GPU hardware is selected in Space settings!
7
+ print("Loading diffusion pipeline...")
8
+ pipe = DiffusionPipeline.from_pretrained(
9
+ "John6666/the-araminta-fv1-sdxl",
10
+ torch_dtype=torch.float16,
11
+ use_safetensors=True,
12
+ token=os.environ.get("HF_TOKEN") # Use token from secrets or OAuth
13
+ )
14
+ if torch.cuda.is_available():
15
+ pipe = pipe.to("cuda")
16
+ else:
17
+ print("WARNING: No CUDA GPU available, using CPU.")
18
 
19
+ def generate_image(prompt, negative_prompt="", guidance_scale=7.5, num_steps=30):
20
+ print(f"Generating image for prompt: {prompt}")
21
+ try:
22
+ image = pipe(
23
+ prompt=prompt,
24
+ negative_prompt=negative_prompt,
25
+ guidance_scale=guidance_scale,
26
+ num_inference_steps=int(num_steps) # Ensure steps is int
27
+ ).images[0]
28
+ print("Image generation successful.")
29
+ return image
30
+ except Exception as e:
31
+ print(f"Error during image generation: {e}")
32
+ raise gr.Error(f"Failed to generate image: {e}")
33
 
34
+ with gr.Blocks() as demo:
35
+ gr.Markdown("# The Araminta FV1 SDXL")
36
+ with gr.Row():
37
+ with gr.Column():
38
+ prompt_input = gr.Textbox(label="Prompt")
39
+ neg_prompt_input = gr.Textbox(label="Negative Prompt", value="")
40
+ gs_input = gr.Slider(label="Guidance Scale", minimum=1, maximum=20, step=0.5, value=7.5)
41
+ steps_input = gr.Slider(label="Inference Steps", minimum=10, maximum=100, step=1, value=30)
42
+ submit_btn = gr.Button("Generate")
43
+ with gr.Column():
44
+ output_image = gr.Image(label="Generated Image")
45
+
46
+ submit_btn.click(
47
+ fn=generate_image,
48
+ inputs=[prompt_input, neg_prompt_input, gs_input, steps_input],
49
+ outputs=output_image
50
+ )
51
+
52
+ print("Launching Gradio interface...")
53
  demo.launch()