Bagda commited on
Commit
570dba4
·
verified ·
1 Parent(s): 5815406

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -1,28 +1,27 @@
1
- import os
2
- import torch
3
- from diffusers import StableDiffusionPipeline
4
- import gradio as gr
5
 
6
- # Hugging Face token from Secrets (for private model access)
7
- HF_TOKEN = os.getenv("HF_TOKEN")
 
8
 
9
- # Load the Anything-V3 model
10
  pipe = StableDiffusionPipeline.from_pretrained(
11
  "Linaqruf/anything-v3.0",
12
- use_auth_token=HF_TOKEN,
13
- torch_dtype=torch.float16
14
- ).to("cuda")
 
15
 
16
- # Main generation function
17
  def generate_thumbnail(prompt):
18
- image = pipe(prompt).images[0]
19
  return image
20
 
21
  # Gradio UI
22
- gr.Interface(
23
  fn=generate_thumbnail,
24
- inputs=gr.Textbox(label="Enter Thumbnail Prompt"),
25
- outputs=gr.Image(type="pil"),
26
- title="Anime/Minecraft Style Thumbnail Generator",
27
- description="Powered by Linaqruf/anything-v3.0 model"
28
- ).launch()
 
 
 
 
 
 
 
1
 
2
+ import gradio as gr
3
+ from diffusers import StableDiffusionPipeline
4
+ import torch
5
 
6
+ # Model load
7
  pipe = StableDiffusionPipeline.from_pretrained(
8
  "Linaqruf/anything-v3.0",
9
+ torch_dtype=torch.float16,
10
+ revision="fp16",
11
+ safety_checker=None
12
+ ).to("cuda" if torch.cuda.is_available() else "cpu")
13
 
 
14
  def generate_thumbnail(prompt):
15
+ image = pipe(prompt, height=512, width=512).images[0]
16
  return image
17
 
18
  # Gradio UI
19
+ iface = gr.Interface(
20
  fn=generate_thumbnail,
21
+ inputs=gr.Textbox(label="Thumbnail Prompt"),
22
+ outputs=gr.Image(label="Generated Thumbnail"),
23
+ title="Anime Thumbnail Generator",
24
+ description="Generate thumbnails using Linaqruf/anything-v3.0 model"
25
+ )
26
+
27
+ iface.launch()