Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,9 +32,31 @@ def text2speech(model, text, voice):
|
|
32 |
speech = synthesiser(text, forward_params={"speaker_embeddings": speaker_embedding})
|
33 |
audio_data = np.frombuffer(speech["audio"], dtype=np.float32)
|
34 |
audio_data_16bit = (audio_data * 32767).astype(np.int16)
|
35 |
-
|
36 |
return speech["sampling_rate"], audio_data_16bit
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
radio1 = gr.Radio(["microsoft/resnet-50", "google/vit-base-patch16-224", "apple/mobilevit-small"], value="microsoft/resnet-50", label="Select a Classifier", info="Image Classifier")
|
39 |
tab1 = gr.Interface(
|
40 |
fn=guessanImage,
|
@@ -57,5 +79,12 @@ tab3 = gr.Interface(
|
|
57 |
outputs=["audio"],
|
58 |
)
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
demo.launch()
|
|
|
32 |
speech = synthesiser(text, forward_params={"speaker_embeddings": speaker_embedding})
|
33 |
audio_data = np.frombuffer(speech["audio"], dtype=np.float32)
|
34 |
audio_data_16bit = (audio_data * 32767).astype(np.int16)
|
|
|
35 |
return speech["sampling_rate"], audio_data_16bit
|
36 |
|
37 |
+
def ImageGenFromText(text, model):
|
38 |
+
api_key = os.getenv("fluxauthtoken")
|
39 |
+
login(token=api_key)
|
40 |
+
|
41 |
+
if len(text) > 0:
|
42 |
+
dtype = torch.bfloat16
|
43 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
44 |
+
MAX_SEED = np.iinfo(np.int32).max
|
45 |
+
seed = random.randint(0, MAX_SEED)
|
46 |
+
pipe = DiffusionPipeline.from_pretrained(model, torch_dtype=dtype).to(device)
|
47 |
+
generator = torch.Generator().manual_seed(seed)
|
48 |
+
image = pipe(
|
49 |
+
prompt = text,
|
50 |
+
width = 512,
|
51 |
+
height = 512,
|
52 |
+
num_inference_steps = 4,
|
53 |
+
generator = generator,
|
54 |
+
guidance_scale=0.0
|
55 |
+
).images[0]
|
56 |
+
print(image)
|
57 |
+
return image
|
58 |
+
|
59 |
+
|
60 |
radio1 = gr.Radio(["microsoft/resnet-50", "google/vit-base-patch16-224", "apple/mobilevit-small"], value="microsoft/resnet-50", label="Select a Classifier", info="Image Classifier")
|
61 |
tab1 = gr.Interface(
|
62 |
fn=guessanImage,
|
|
|
79 |
outputs=["audio"],
|
80 |
)
|
81 |
|
82 |
+
radio3 = gr.Radio(["black-forest-labs/FLUX.1-schnell"], value="black-forest-labs/FLUX.1-schnell", label="Select", info="text to image")
|
83 |
+
tab4 = gr.Interface(
|
84 |
+
fn=ImageGenFromText,
|
85 |
+
inputs=["text", "model"],
|
86 |
+
outputs=["image"],
|
87 |
+
)
|
88 |
+
|
89 |
+
demo = gr.TabbedInterface([tab1, tab2, tab3, tab4], ["tab1", "tab2", "tab3", "tab4"])
|
90 |
demo.launch()
|