Skip to content
This repository was archived by the owner on Apr 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions freestream/pages/2_🖼️_Image_Upscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# Initialize page config
st.set_page_config(page_title="FreeStream: Image Upscaler", page_icon="🖼️")
st.title("🖼️Image Upscaler")
st.header(":green[_⚠️Under Construction⚠️_]", divider="red")
#st.header(":green[_⚠️Under Construction⚠️_]", divider="red")
st.caption(
":violet[_This page is still under construction. Processing speed and output quality will improve over time._]"
":violet[_This page is still under construction. Stability, processing speed and output quality will improve in time._]"
)

# Show footer
Expand All @@ -36,11 +36,9 @@

**Limitations**:

* Images with a width *or* height greater than 128 will be downsampled by 3/20ths. This limitation will be removed once Real-ESRGAN is implemented.
* Images with a width *or* height greater than 300 will not be upscaled due to resource limitations of this environment.
* The current upscaler problematically generates new content around the edge of the image, especially on the right side.

As with all FreeStream pages, this one's purpose is merely to show you the possibilities without having to sign up or program anything manually.
Right now, having a page that "works" is an important step in that it lays down the foundation for a robust solution.
"""
)

Expand Down
24 changes: 6 additions & 18 deletions freestream/pages/utils/utility_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ def set_llm(selected_model: str, model_names: dict):
st.error(f"Failed to change model! Error: {e}\n{selected_model}")


# Define a callback function for clearing the conversation history
def clear_messages(msgs: StreamlitChatMessageHistory):
"""
Clears the conversation history in the user interface.
"""
msgs.clear()


class StreamHandler(BaseCallbackHandler):
"""
A callback handler for streaming the model's output to the user interface.
Expand Down Expand Up @@ -257,20 +249,16 @@ def image_upscaler(image: str) -> Image:
device="cuda" if torch.cuda.is_available() else "cpu",
)

# Downsize the image via ratio to ensure it can be upscaled.
# Otherwise, we run out of memory when a user uploads a huge image.
# If the image is greater than 1024 in either dimension, then
# the image is downsampled by a factor of 3.
if img.width > 128 or img.height > 128:
st.toast("Downsampling image...", icon="🔨")
logger.info("\nDownsampling image...")
img = img.resize((int(img.width * 0.15), int(img.height * 0.15)))
# If the image is greater than 300 in either dimension, then
# stop the application
if img.width > 300 or img.height > 300:
st.stop("Image is too large. Please upload an image with a width and height less than 300.")
else:
img = img
pass

# Upscale the image
st.toast("Upscaling image...", icon="🔨")
logger.info("\nUpscaling image...")
logger.info(f"\nUpscaling {img}...")
upscaled_img = upscaler(img)
st.toast("Success!", icon="✅")

Expand Down
Loading