File size: 2,225 Bytes
4f038ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 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...