MCPcopy Create free account
hub / github.com/codingis4noobs2/QuickDigest / generate_images

Function generate_images

app.py:518–558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

516
517# Function to generate images based on user input
518def generate_images():
519 import streamlit as st
520 import replicate
521 import os
522
523
524 st.session_state['replicate_api_token'] = st.sidebar.text_input("Replicate API Token", type='password')
525 os.environ['REPLICATE_API_TOKEN'] = st.session_state['replicate_api_token']
526
527 if not st.session_state['replicate_api_token']:
528 st.sidebar.warning('Please enter your Replicate API Token to continue!!')
529 st.sidebar.info("You can get your Replicate API Token form here: [Replicate](https://replicate.com/account/api-tokens)")
530 st.stop()
531
532 if st.session_state['replicate_api_token']:
533 prompt = st.text_input(
534 "Enter prompt",
535 help="Write something you can imagine..."
536 )
537 negative_prompt = st.text_input(
538 "Enter Negative prompt",
539 help="Write what you don't want to see in the generated images"
540 )
541 submit = st.button("Submit")
542
543 if submit:
544 output = replicate.run(
545 "stability-ai/sdxl:8beff3369e81422112d93b89ca01426147de542cd4684c244b673b105188fe5f",
546 input={
547 "prompt": prompt,
548 "negative_prompt": negative_prompt,
549 "num_outputs": 4
550 },
551 )
552 col1, col2 = st.columns(2)
553 with col1:
554 st.image(output[0])
555 st.image(output[2])
556 with col2:
557 st.image(output[1])
558 st.image(output[3])
559
560# Dictonary to store all functions as pages
561page_names_to_funcs = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected