Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -92,20 +92,48 @@ with left:
|
|
| 92 |
st.text_input("Calculation", st.session_state.calc_input, key="display", disabled=True)
|
| 93 |
|
| 94 |
with lr:
|
| 95 |
-
# End of Box 1 and first Carousel Item
|
| 96 |
-
st.markdown('''<h3><i class="fa fa-pencil"></i> Form 1</h3>''', unsafe_allow_html=True)
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
# Button to trigger generation
|
| 102 |
if st.button("Generate Prompt"):
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
else:
|
| 108 |
-
st.error("
|
|
|
|
| 109 |
|
| 110 |
with rl:
|
| 111 |
# End of Box 2 and second Carousel Item
|
|
@@ -131,16 +159,16 @@ with rl:
|
|
| 131 |
with st.spinner("Transcribing..."):
|
| 132 |
#transcription = transcribe("temp_recording.wav")
|
| 133 |
#need to send the data here
|
|
|
|
| 134 |
print("")
|
| 135 |
st.text_area("Transcription", transcription, height=200)
|
| 136 |
else:
|
| 137 |
-
st.error("Please record audio or upload a file to transcribe.")
|
|
|
|
| 138 |
|
| 139 |
-
# End of Box 3 and third Carousel Item
|
| 140 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Chat with Mistral</h3>''', unsafe_allow_html=True)
|
| 141 |
-
with right:
|
| 142 |
# Box 4: Form 3
|
| 143 |
-
prompt3 = st.text_input("Enter Prompt", key="prompt3")
|
| 144 |
#image_url3 = st.text_input("Enter Image URL", key="image_url3")
|
| 145 |
if st.button("Submit", key="submit3"):
|
| 146 |
payload = {"prompt": prompt3}
|
|
|
|
| 92 |
st.text_input("Calculation", st.session_state.calc_input, key="display", disabled=True)
|
| 93 |
|
| 94 |
with lr:
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
st.markdown('''<h3><i class="fa fa-image"></i> Gen Image</h3>''', unsafe_allow_html=True)
|
| 97 |
+
|
| 98 |
+
api_key = f"{BASETEN_KEY}"
|
| 99 |
+
negative_prompt = st.text_input("Negative Prompt", "blurry, text, low quality")
|
| 100 |
+
positive_prompt = st.text_input("Positive Prompt", "An igloo on a snowy day, 4k, hd")
|
| 101 |
+
controlnet_image_url = st.text_input("ControlNet Image URL", "https://storage.googleapis.com/logos-bucket-01/baseten_logo.png")
|
| 102 |
+
|
| 103 |
+
|
| 104 |
|
| 105 |
# Button to trigger generation
|
| 106 |
if st.button("Generate Prompt"):
|
| 107 |
+
# Making the API request
|
| 108 |
+
response = requests.post(
|
| 109 |
+
"https://model-7wlx9oew.api.baseten.co/production/predict",
|
| 110 |
+
headers={"Authorization": f"Api-Key {api_key}"},
|
| 111 |
+
json={
|
| 112 |
+
'workflow_values': {
|
| 113 |
+
'negative_prompt': negative_prompt,
|
| 114 |
+
'positive_prompt': positive_prompt,
|
| 115 |
+
'controlnet_image': controlnet_image_url
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# Display the response
|
| 121 |
+
if response.status_code == 200:
|
| 122 |
+
result = response.json().get("result")
|
| 123 |
+
if result:
|
| 124 |
+
image_data = result[0].get("data")
|
| 125 |
+
if image_data:
|
| 126 |
+
# Decode the base64 image data
|
| 127 |
+
image = base64.b64decode(image_data)
|
| 128 |
+
# Display the image in Streamlit
|
| 129 |
+
st.image(image, caption="Generated Image", use_column_width=True)
|
| 130 |
+
else:
|
| 131 |
+
st.error("No image data found in the response.")
|
| 132 |
+
else:
|
| 133 |
+
st.error("No result found in the response.")
|
| 134 |
else:
|
| 135 |
+
st.error(f"Error: {response.status_code}, {response.text}")
|
| 136 |
+
|
| 137 |
|
| 138 |
with rl:
|
| 139 |
# End of Box 2 and second Carousel Item
|
|
|
|
| 159 |
with st.spinner("Transcribing..."):
|
| 160 |
#transcription = transcribe("temp_recording.wav")
|
| 161 |
#need to send the data here
|
| 162 |
+
transcription = "Under Process"
|
| 163 |
print("")
|
| 164 |
st.text_area("Transcription", transcription, height=200)
|
| 165 |
else:
|
| 166 |
+
st.error("Please record audio or upload a file to transcribe.")
|
| 167 |
+
with right:
|
| 168 |
|
|
|
|
| 169 |
st.markdown('''<h3><i class="fa fa-pencil"></i> Chat with Mistral</h3>''', unsafe_allow_html=True)
|
|
|
|
| 170 |
# Box 4: Form 3
|
| 171 |
+
prompt3 = st.text_input("Enter Prompt", key="prompt3", value="Why is Sky Blue?")
|
| 172 |
#image_url3 = st.text_input("Enter Image URL", key="image_url3")
|
| 173 |
if st.button("Submit", key="submit3"):
|
| 174 |
payload = {"prompt": prompt3}
|