Update app.py
Browse files
app.py
CHANGED
|
@@ -82,45 +82,6 @@ with gr.Blocks(css='style.css') as myface:
|
|
| 82 |
magic5 = gr.Textbox(label="Generated Prompt", lines=2)
|
| 83 |
magic6 = gr.Textbox(label="Generated Prompt", lines=2)
|
| 84 |
|
| 85 |
-
|
| 86 |
-
# Set up the GUI
|
| 87 |
-
with Blocks() as demo:
|
| 88 |
-
# Create a State variable to store the selected image
|
| 89 |
-
img = State()
|
| 90 |
-
|
| 91 |
-
# Define a function to load the image from the local storage directory
|
| 92 |
-
def load_image(directory):
|
| 93 |
-
# Get the list of files in the directory
|
| 94 |
-
filenames = os.listdir(directory)
|
| 95 |
-
|
| 96 |
-
# Select the first image file (e.g. "image1.jpg")
|
| 97 |
-
filename = filenames[0]
|
| 98 |
-
|
| 99 |
-
# Load the image using numpy.load()
|
| 100 |
-
img_data = np.load(os.path.join(directory, filename))
|
| 101 |
-
|
| 102 |
-
# Convert the image data to a NumPy array
|
| 103 |
-
img = np.array(img_data)
|
| 104 |
-
return img
|
| 105 |
-
|
| 106 |
-
# Create a Gallery widget to display the loaded image
|
| 107 |
-
gallery = Gallery(directory='home/downloads/images')
|
| 108 |
-
|
| 109 |
-
# Add the image to the gallery
|
| 110 |
-
gallery.add(img)
|
| 111 |
-
|
| 112 |
-
# Create a Button widget to trigger the darkening of the image
|
| 113 |
-
darken_btn = Button("Darken Image")
|
| 114 |
-
|
| 115 |
-
# Define a function to darken the image
|
| 116 |
-
def darken_img(img):
|
| 117 |
-
# Darken the image by multiplying each pixel value by 0.8
|
| 118 |
-
darkened_img = np.round(img * 0.8).astype(np.uint8)
|
| 119 |
-
return darkened_img
|
| 120 |
-
|
| 121 |
-
# Connect the Button widget to the darken_img function
|
| 122 |
-
darken_btn.click(darken_img, [img], [gallery])
|
| 123 |
-
|
| 124 |
# Launch the GUI
|
| 125 |
demo.launch()
|
| 126 |
|
|
|
|
| 82 |
magic5 = gr.Textbox(label="Generated Prompt", lines=2)
|
| 83 |
magic6 = gr.Textbox(label="Generated Prompt", lines=2)
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
# Launch the GUI
|
| 86 |
demo.launch()
|
| 87 |
|