RanM commited on
Commit
1a4c9cb
verified
1 Parent(s): 32dda0b

Update generate_propmts.py

Browse files
Files changed (1) hide show
  1. generate_propmts.py +13 -20
generate_propmts.py CHANGED
@@ -82,24 +82,17 @@ def get_image_from_space(text, sentence_mapping, character_dict, selected_style,
82
  bytes: The generated image data in bytes format, or None if the request fails.
83
  """
84
  image_bytes = None # Initialize image bytes to None for error handling
85
- try:
86
- with st.spinner("注讜讚 讻诪讛 专讙注讬诐 讜讛讗讬讜专 讬讜驻讬注"):
87
- # Define the payload with the text prompt
88
- prompt,_ = generate_prompt(text, sentence_mapping, character_dict, selected_style)
89
- payload = {
90
- "inputs": prompt
91
- }
92
- result = client.predict(
93
- prompt=payload,
94
- api_name="/predict"
95
- )
96
 
97
- # Check if the result is a base64 encoded string
98
- if isinstance(result, str):
99
- image_bytes = base64.b64decode(result)
100
- return image_bytes
101
- else:
102
- st.error("讗讜讬 诇讗 谞讬转谉 诇讬讬爪专 转诪讜谞讛, 讬砖 诇谞住讜转 砖讜讘 讘讛诪砖讱")
103
- except Exception as e:
104
- print(f"讗讜讬 诇讗 谞讬转谉 诇讬讬爪专 转诪讜谞讛, 讬砖 诇谞住讜转 砖讜讘 讘讛诪砖讱: {e}")
105
- return image_bytes
 
82
  bytes: The generated image data in bytes format, or None if the request fails.
83
  """
84
  image_bytes = None # Initialize image bytes to None for error handling
85
+ # Define the payload with the text prompt
86
+ prompt,_ = generate_prompt(text, sentence_mapping, character_dict, selected_style)
87
+ payload = {
88
+ "inputs": prompt
89
+ }
90
+ result = client.predict(
91
+ prompt=payload,
92
+ api_name="/predict"
93
+ )
 
 
94
 
95
+ # Check if the result is a base64 encoded string
96
+ if isinstance(result, str):
97
+ image_bytes = base64.b64decode(result)
98
+ return image_bytes