Bagda commited on
Commit
1ab63ce
·
verified ·
1 Parent(s): 76a4f6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -23
app.py CHANGED
@@ -1,30 +1,28 @@
1
- import gradio as gr
2
- from diffusers import StableDiffusionImg2ImgPipeline
3
  import torch
4
- from PIL import Image
 
5
 
6
- # Load pretrained model
7
- pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
8
- "runwayml/stable-diffusion-v1-5",
9
- torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
10
- use_auth_token=True # Use secret token
 
11
  )
12
- pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")
13
 
14
- # Main function
15
- def generate_thumbnail(prompt, image):
16
- image = image.resize((512, 512)).convert("RGB")
17
- result = pipe(prompt=prompt, image=image, strength=0.75, guidance_scale=7.5)
18
- return result.images[0]
19
 
20
  # Gradio UI
21
- gr.Interface(
22
  fn=generate_thumbnail,
23
- inputs=[
24
- gr.Textbox(label="Prompt (e.g. 'Minecraft NOOB vs PRO battle')"),
25
- gr.Image(type="pil", label="Upload Background Image")
26
- ],
27
- outputs=gr.Image(label="Generated Thumbnail"),
28
- title="🖼️ AI Thumbnail Generator",
29
- description="Enter prompt and image to create YouTube-style thumbnails"
30
- ).launch()
 
 
 
1
  import torch
2
+ from diffusers import StableDiffusionPipeline
3
+ import gradio as gr
4
 
5
+ # Model Load करो
6
+ pipe = StableDiffusionPipeline.from_pretrained(
7
+ "Linaqruf/anything-v3.0",
8
+ torch_dtype=torch.float16,
9
+ revision="fp16",
10
+ safety_checker=None
11
  )
12
+ pipe = pipe.to("cuda")
13
 
14
+ # Thumbnail generate करने वाला function
15
+ def generate_thumbnail(prompt):
16
+ image = pipe(prompt).images[0]
17
+ return image
 
18
 
19
  # Gradio UI
20
+ interface = gr.Interface(
21
  fn=generate_thumbnail,
22
+ inputs=gr.Textbox(label="Enter Prompt", placeholder="e.g. Minecraft thumbnail, anime character"),
23
+ outputs=gr.Image(type="pil", label="Generated Thumbnail"),
24
+ title="Thumbnail Generator (Anime Style)",
25
+ description="Enter your prompt to generate an anime-style thumbnail using Anything-v3.0"
26
+ )
27
+
28
+ interface.launch()