Spaces:
Runtime error
Runtime error
| # text_to_scene.py | |
| import streamlit as st | |
| import replicate | |
| import os | |
| def generate_scene(text_prompt, additional_context): | |
| try: | |
| # Ensure the API key is set | |
| if "REPLICATE_API_TOKEN" not in os.environ: | |
| raise ValueError("REPLICATE_API_TOKEN is not set in environment variables") | |
| output_quality = additional_context.get('output_quality', 80) | |
| input_data = { | |
| "prompt": text_prompt, | |
| "output_quality": output_quality | |
| } | |
| output = replicate.run( | |
| "aramintak/flux-film-foto:f43477e89617ab7bc66f93731b5027d6e46c116ff7b7dce7f5ffccb39a01b375", | |
| input=input_data | |
| ) | |
| return output | |
| except Exception as e: | |
| st.error(f"Error in generate_scene: {str(e)}") | |
| return None | |
| def process_text_to_scene(result): | |
| if result is None: | |
| st.error("Failed to generate scene. Please check the logs for more details.") | |
| return | |
| try: | |
| # Display the generated scene | |
| st.write("### Generated Scene") | |
| st.image(result[0], use_column_width=True) | |
| # Display additional information | |
| st.write("### Generation Details") | |
| st.write(f"- Image URL: {result[0]}") | |
| except Exception as e: | |
| st.error(f"Error processing data for Text to Scene: {e}") | |
| st.write("Please check the structure of the API response:") | |
| st.write(result) | |
| # import replicate | |
| # input = { | |
| # "prompt": "Bahubali-style hero reveal. Muscular warrior atop 100-foot ancient statue's shoulder. Hero wears golden armor, blue cape. Wields glowing flexible sword. Statue emerges from misty waterfall. Thousands of soldiers salute below. Elephants with ornate howdahs in foreground. Storm clouds, shafts of sunlight. Lightning strikes as hero raises sword. Hyper-detailed, epic scale, 8K resolution. S.S. Rajamouli's grand visual style.", | |
| # "output_quality": 80 | |
| # } | |
| # output = replicate.run( | |
| # "aramintak/flux-film-foto:f43477e89617ab7bc66f93731b5027d6e46c116ff7b7dce7f5ffccb39a01b375", | |
| # input=input | |
| # ) | |
| # print(output) | |
| # #=> ["https://replicate.delivery/yhqm/ypzOQ7scoYKoCd3j1n7eZwO... |