Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,34 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
im1 = PILImage.create('Brittlebush-Encelia-Farinosa-desert-horizon-nursery.jpg')
|
| 5 |
-
im2 = PILImage.create('download.webp')
|
| 6 |
|
| 7 |
learn = load_learner('export.pkl')
|
| 8 |
|
| 9 |
-
pred_class,pred_idx,probabilities = learn.predict(im1)
|
| 10 |
-
pred_class, pred_idx, probabilities
|
| 11 |
-
|
| 12 |
-
pred_class,pred_idx,probabilities = learn.predict(im2)
|
| 13 |
-
pred_class, pred_idx, probabilities
|
| 14 |
-
|
| 15 |
categories = ('balsamroot', 'bladderpod', 'blazing star', 'bristlecone pine flowers', 'brittlebrush')
|
| 16 |
def classify_image(img):
|
| 17 |
pred, idx, probs = learn.predict(img)
|
| 18 |
return dict(zip(categories, map(float, probs)))
|
| 19 |
|
| 20 |
|
| 21 |
-
classify_image(im1), classify_image(im2)
|
| 22 |
|
| 23 |
image=gr.Image(height = 192, width = 192)
|
| 24 |
label = gr.Label()
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
+
from huggingface_hub import login
|
| 4 |
+
login()
|
| 5 |
+
import torch
|
| 6 |
+
from diffusers import FluxPipeline
|
| 7 |
+
|
| 8 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
| 9 |
+
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power
|
| 10 |
+
|
| 11 |
+
prompt = "A cat holding a sign that says hello world"
|
| 12 |
+
image = pipe(
|
| 13 |
+
prompt,
|
| 14 |
+
height=1024,
|
| 15 |
+
width=1024,
|
| 16 |
+
guidance_scale=3.5,
|
| 17 |
+
num_inference_steps=50,
|
| 18 |
+
max_sequence_length=512,
|
| 19 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
| 20 |
+
).images[0]
|
| 21 |
+
image.save("flux-dev.png")
|
| 22 |
|
|
|
|
|
|
|
| 23 |
|
| 24 |
learn = load_learner('export.pkl')
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
categories = ('balsamroot', 'bladderpod', 'blazing star', 'bristlecone pine flowers', 'brittlebrush')
|
| 27 |
def classify_image(img):
|
| 28 |
pred, idx, probs = learn.predict(img)
|
| 29 |
return dict(zip(categories, map(float, probs)))
|
| 30 |
|
| 31 |
|
|
|
|
| 32 |
|
| 33 |
image=gr.Image(height = 192, width = 192)
|
| 34 |
label = gr.Label()
|