Text-to-Image
Diffusers
PyTorch
Safetensors
StableDiffusionPipeline
clip
stable diffusion
comics
text to image
Instructions to use rowenac/vintagechinesecomics with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use rowenac/vintagechinesecomics with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("rowenac/vintagechinesecomics", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Download react app/client/src/App.js from rowenac/vintagechinesecomics: direct link, hf CLI and curl.
- Browser
- Download file 3.11 kB
-
https://huggingface.co/rowenac/vintagechinesecomics/resolve/main/react%20app/client/src/App.js
- Command line
-
hf download 'hf://rowenac/vintagechinesecomics/react app/client/src/App.js'
-
curl -L -o App.js https://huggingface.co/rowenac/vintagechinesecomics/resolve/main/react%20app/client/src/App.js
3.11 kB
| import React, { useState, useEffect } from "react"; | |
| import axios from "axios"; | |
| import { | |
| ChakraProvider, | |
| Container, | |
| Heading, | |
| Text, | |
| Input, | |
| Button, | |
| Wrap, | |
| Link, | |
| } from "@chakra-ui/react"; // Import Chakra UI components | |
| import "./Gallery.css"; // Import your Gallery CSS here | |
| const Gallery = ({ images }) => { | |
| return ( | |
| <div className="gallery"> | |
| {images.map((image, index) => ( | |
| <img | |
| key={index} | |
| src={`http://127.0.0.1:8000/api/get_image/${image}`} // Replace with your API endpoint | |
| alt={`Image ${index}`} | |
| className="gallery-image" | |
| /> | |
| ))} | |
| </div> | |
| ); | |
| }; | |
| const App = () => { | |
| const [image, updateImage] = useState(); | |
| const [prompt, updatePrompt] = useState(""); | |
| const [loading, updateLoading] = useState(false); | |
| const [showGallery, setShowGallery] = useState(false); | |
| const [galleryImages, setGalleryImages] = useState([]); | |
| const generate = async (prompt) => { | |
| updateLoading(true); | |
| const result = await axios.get(`http://127.0.0.1:8000/?prompt=${prompt}`); | |
| updateImage(result.data); | |
| updateLoading(false); | |
| }; | |
| useEffect(() => { | |
| // Fetch image filenames from the backend API when the component mounts | |
| axios.get("http://127.0.0.1:8000/api/get_images").then((response) => { | |
| setGalleryImages(response.data); | |
| }); | |
| }, []); | |
| return ( | |
| <ChakraProvider> | |
| <Container> | |
| <Heading>70年小人书: Vintage Chinese Comics Generator</Heading> | |
| <Text marginBottom={"10px"}> | |
| Click on the generate button to generate an image from a Stable Diffusion 1.5 model trained on vintage Chinese comics. This is an all-ages friendly, SFW model. If NSFW content is detected, the generated image will return as a black square. If that happens, just try again.{" "} | |
| <Link href={"https://github.com/CompVis/stable-diffusion"}> | |
| Original SD 1.5 Github Repo | |
| </Link> | |
| <Link href={"https://huggingface.co/rowenac/vintagechinesecomics"}> | |
| Huggingface Repo for this model | |
| </Link> | |
| <Link href={"https://github.com/nicknochnack"}> | |
| frontend and backend code based on Nicholas Renotte's repo | |
| </Link> | |
| </Text> | |
| <Wrap marginBottom={"10px"}> | |
| <Input | |
| value={prompt} | |
| onChange={(e) => updatePrompt(e.target.value)} | |
| width={"350px"} | |
| ></Input> | |
| <Button onClick={() => generate(prompt)} colorScheme={"yellow"}> | |
| Generate | |
| </Button> | |
| </Wrap> | |
| {loading ? ( | |
| <div>Loading...</div> | |
| ) : image ? ( | |
| <div> | |
| <img | |
| src={`data:image/png;base64,${image}`} | |
| alt="Generated" | |
| style={{ boxShadow: "lg" }} | |
| /> | |
| <center><Button onClick={() => setShowGallery(!showGallery)} colorScheme={"yellow"}> | |
| Toggle Gallery | |
| </Button></center> | |
| {showGallery && <Gallery images={galleryImages} />} | |
| </div> | |
| ) : null} | |
| </Container> | |
| </ChakraProvider> | |
| ); | |
| }; | |
| export default App; | |