analitics

Pages

Showing posts with label torch. Show all posts
Showing posts with label torch. Show all posts

Thursday, January 9, 2025

Python 3.10.12 : Simple test with diffusers to create texture.

Today I tested on colab a simple python script to generate a texture using: diffusers, torch and gradio.
I upload the notebook on my colab repo from GitHub.
The script is simple and works good:
import gradio as gr
from diffusers import StableDiffusionPipeline
import torch

model_id = "dream-textures/texture-diffusion"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

def generate_image(prompt):
    image = pipe(prompt).images[0]
    image.save("result.png")
    return image

iface = gr.Interface(
    fn=generate_image,
    inputs="text",
    outputs="image",
    title="Stable Diffusion Image Generator",
    description="Introduceți un prompt pentru a genera o imagine folosind Stable Diffusion."
)

iface.launch()
The result for the pbr winter terrain is this image: