import gradio as gr from inference_code import generate_images def generate_image_predictions(prompt): images = generate_images(prompt) return images demo = gr.Blocks() with demo: gr.Markdown( """ # 🌍 Map Diffuser Below we present a Stable Diffusion text to image model that will generate map tiles based on a text prompt. We trained it on just 10k images and prompts based on openstreetmap. Images were from @mapbox satellite images + @StamenDesign water color and toner images + @carto's Voyager style. The region trained was limited to central Europe and more precisely Prague and Amsterdam. This was part of the Hackathon run by Hugging Face & Google to use JAX API with Google Gen4 TPUs that are especially designed to train massive models. The model tuning led to some surprising results. For example we didn't have any prompts with "ships" or "desert" yet when passed that it tried to add ships to the satellite images 🤷‍♂️... """ ) input = gr.components.Textbox(label="Enter a text prompt here") output = gr.components.Image(label="Output Image") # button to submit the prompt button = gr.components.Button(label="Generate") # when the button is clicked, call the generate_image_predictions function # and pass in the prompt as an argument button.click(generate_image_predictions, inputs=input, outputs=output) gr.Markdown( """ ### Generates images from a given text prompt. The prompts are in the format: - `{style} map of {city} with {features}` or - `satellite image of {city} with {features}` or - `satellite image with {features}` or - `satellite image of {city} with {features} and no {features}` and so on... ### So for example: - "Satellite image of amsterdam with industrial area and highways" - "Watercolor style map of Amsterdam with residential area and highways" - "Toner style map of Amsterdam with residential area and highways" - "Satellite image with forests and residential, no water" Examples table: | Prompt | Output | | --- | --- | | Satellite image of industrial area with ships | | | Watercolor style map of Amsterdam with residential area and highways | | | Toner style map of Amsterdam with residential area and highways | | | Satellite image with forests and residential, no water | | """ ) demo.launch()