Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,10 +30,8 @@ def generate_compliment(image):
|
|
| 30 |
captioning_space = spaces.connect("gokaygokay/sd3-long-captioner")
|
| 31 |
|
| 32 |
# Predict caption for the provided image
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
# Extract the caption from the response
|
| 36 |
-
caption_text = caption.data[0]
|
| 37 |
|
| 38 |
except Exception as e:
|
| 39 |
return "Error", f"Failed to get caption. Exception: {e}"
|
|
@@ -53,8 +51,8 @@ def generate_compliment(image):
|
|
| 53 |
"repetition_penalty": 1,
|
| 54 |
}
|
| 55 |
|
| 56 |
-
|
| 57 |
-
compliment_text =
|
| 58 |
|
| 59 |
except Exception as e:
|
| 60 |
return "Error", f"Failed to generate compliment. Exception: {e}"
|
|
@@ -64,7 +62,7 @@ def generate_compliment(image):
|
|
| 64 |
# Gradio interface setup
|
| 65 |
iface = gr.Interface(
|
| 66 |
fn=generate_compliment,
|
| 67 |
-
inputs=gr.inputs.Image(
|
| 68 |
outputs=[
|
| 69 |
gr.outputs.Textbox(label="Caption"),
|
| 70 |
gr.outputs.Textbox(label="Compliment")
|
|
|
|
| 30 |
captioning_space = spaces.connect("gokaygokay/sd3-long-captioner")
|
| 31 |
|
| 32 |
# Predict caption for the provided image
|
| 33 |
+
caption_response = captioning_space.predict("/create_captions_rich", { "image": image_bytes })
|
| 34 |
+
caption_text = caption_response.data[0]
|
|
|
|
|
|
|
| 35 |
|
| 36 |
except Exception as e:
|
| 37 |
return "Error", f"Failed to get caption. Exception: {e}"
|
|
|
|
| 51 |
"repetition_penalty": 1,
|
| 52 |
}
|
| 53 |
|
| 54 |
+
compliment_response = llm_space.run(llm_payload)
|
| 55 |
+
compliment_text = compliment_response.data[0]
|
| 56 |
|
| 57 |
except Exception as e:
|
| 58 |
return "Error", f"Failed to generate compliment. Exception: {e}"
|
|
|
|
| 62 |
# Gradio interface setup
|
| 63 |
iface = gr.Interface(
|
| 64 |
fn=generate_compliment,
|
| 65 |
+
inputs=gr.inputs.Image(label="Upload Image"),
|
| 66 |
outputs=[
|
| 67 |
gr.outputs.Textbox(label="Caption"),
|
| 68 |
gr.outputs.Textbox(label="Compliment")
|