CoolFace
Apppublic

AideepImage/interior-design

sourceHugging Faceopenrailupdated 2y agoView on Hugging Face
1likes
explanation.py52 linesDownload Raw Back to root
1import streamlit as st2 3def make_inpainting_explanation():4    with st.expander("Explanation inpainting", expanded=False):5        st.write("In the inpainting mode, you can draw regions on the input image that you want to regenerate. "6                "This can be useful to remove unwanted objects from the image or to improve the consistency of the image."7                )8        st.image("content/inpainting_sidebar.png", caption="Image before inpainting, note the ornaments on the wall", width=500)9        st.write("You can find drawing options in the sidebar. There are two modes: freedraw and polygon. Freedraw allows the user to draw with a pencil of a certain width. "10                 "Polygon allows the user to draw a polygon by clicking on the image to add a point. The polygon is closed by right clicking.")11 12        st.write("### Example inpainting")13        st.write("In the example below, the ornaments on the wall are removed. The inpainting is done by drawing a mask on the image.")14        st.image("content/inpainting_before.jpg", caption="Image before inpainting, note the ornaments on the wall")15        st.image("content/inpainting_after.png", caption="Image before inpainting, note the ornaments on the wall")16        17def make_regeneration_explanation():18    with st.expander("Explanation object regeneration"):19        st.write("In this object regeneration mode, the model calculates which objects occur in the image. "20                 "The user can then select which objects can be regenerated by the controlnet model by adding them in the multiselect box. "21                 "All the object classes that are not selected will remain the same as in the original image."22                 )23        st.write("### Example object regeneration")24        st.write("In the example below, the room consists of various objects such as wall, ceiling, floor, lamp, bed, ... "25                 "In the multiselect box, all the objects except for 'lamp', 'bed and 'table' are selected to be regenerated. "26                 )27        st.image("content/regen_example.png", caption="Room where all concepts except for 'bed', 'lamp', 'table' are regenerated")28 29def make_segmentation_explanation():30    with st.expander("Segmentation mode", expanded=False):31        st.write("In the segmentation mode, the user can use his imagination and the paint brush to place concepts in the image. "32                 "In the left sidebar, you can first find the high level category of the concept you want to add, such as 'lighting', 'floor', .. "33                 "After selecting the category, you can select the specific concept you want to add in the 'Choose a color' dropdown. "34                 "This will change the color of the paint brush, which you can then use to draw on the input image. "35                 "The model will then regenerate the image with the concepts you have drawn and leave the rest of the image unchanged. "36                 )37        st.image("content/sidebar segmentation.png", caption="Sidebar with segmentation options", width=300)38        st.write("You can choose the freedraw mode which gives you a pencil of a certain (chosen) width or the polygon mode. With the polygon mode you can click to add a point to the polygon and close the polygon by right clicking. ")39        st.write("Important: "40                 "it's not easy to draw a good segmentation mask. This is because you need to keep in mind the perspective of the room and the exact "41                 "shape of the object you want to draw within this perspective. Controlnet will follow your segmentation mask pretty well, so "42                 "a non-natural object shape will sometimes result in weird outputs. However, give it a try and see what you can do! "43                 )44        st.image("content/segmentation window.png", caption="Example of a segmentation mask drawn on the input image to add a window to the room")45        st.write("Tip: ")46        st.write("In the concepts dropdown, you can select 'keep background' (which is a white color). Everything drawn in this color will use "47                 "the original underlying segmentation mask. This can be useful to help with generating other objects, since you give the model a some "48                 "freedom to generate outside the object borders."49                 )50        st.image("content/keep background 1.png", caption="Image with a poster drawn on the wall.")51        st.image("content/keep background 2.png", caption="Image with a poster drawn on the wall surrounded by 'keep background'.")52