Upload 8 files
Browse files- .gitattributes +1 -0
- 1.jpg +0 -0
- 2.jpg +0 -0
- 3.jpg +0 -0
- 4.jpg +0 -0
- 5.jpg +0 -0
- 6.jpg +0 -0
- Doggos.keras +3 -0
- app.py +29 -143
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
Doggos.keras filter=lfs diff=lfs merge=lfs -text
|
1.jpg
ADDED
|
2.jpg
ADDED
|
3.jpg
ADDED
|
4.jpg
ADDED
|
5.jpg
ADDED
|
6.jpg
ADDED
|
Doggos.keras
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f46f2c3cba2fcbf6f6f2470ba6331ee8e46c87d2e14abc870a798857e555a003
|
| 3 |
+
size 250633864
|
app.py
CHANGED
|
@@ -1,146 +1,32 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
-
import random
|
| 4 |
-
from diffusers import DiffusionPipeline
|
| 5 |
-
import torch
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
height = height,
|
| 35 |
-
generator = generator
|
| 36 |
-
).images[0]
|
| 37 |
-
|
| 38 |
-
return image
|
| 39 |
-
|
| 40 |
-
examples = [
|
| 41 |
-
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
| 42 |
-
"An astronaut riding a green horse",
|
| 43 |
-
"A delicious ceviche cheesecake slice",
|
| 44 |
-
]
|
| 45 |
-
|
| 46 |
-
css="""
|
| 47 |
-
#col-container {
|
| 48 |
-
margin: 0 auto;
|
| 49 |
-
max-width: 520px;
|
| 50 |
-
}
|
| 51 |
-
"""
|
| 52 |
-
|
| 53 |
-
if torch.cuda.is_available():
|
| 54 |
-
power_device = "GPU"
|
| 55 |
-
else:
|
| 56 |
-
power_device = "CPU"
|
| 57 |
-
|
| 58 |
-
with gr.Blocks(css=css) as demo:
|
| 59 |
-
|
| 60 |
-
with gr.Column(elem_id="col-container"):
|
| 61 |
-
gr.Markdown(f"""
|
| 62 |
-
# Text-to-Image Gradio Template
|
| 63 |
-
Currently running on {power_device}.
|
| 64 |
-
""")
|
| 65 |
-
|
| 66 |
-
with gr.Row():
|
| 67 |
-
|
| 68 |
-
prompt = gr.Text(
|
| 69 |
-
label="Prompt",
|
| 70 |
-
show_label=False,
|
| 71 |
-
max_lines=1,
|
| 72 |
-
placeholder="Enter your prompt",
|
| 73 |
-
container=False,
|
| 74 |
-
)
|
| 75 |
-
|
| 76 |
-
run_button = gr.Button("Run", scale=0)
|
| 77 |
-
|
| 78 |
-
result = gr.Image(label="Result", show_label=False)
|
| 79 |
-
|
| 80 |
-
with gr.Accordion("Advanced Settings", open=False):
|
| 81 |
-
|
| 82 |
-
negative_prompt = gr.Text(
|
| 83 |
-
label="Negative prompt",
|
| 84 |
-
max_lines=1,
|
| 85 |
-
placeholder="Enter a negative prompt",
|
| 86 |
-
visible=False,
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
seed = gr.Slider(
|
| 90 |
-
label="Seed",
|
| 91 |
-
minimum=0,
|
| 92 |
-
maximum=MAX_SEED,
|
| 93 |
-
step=1,
|
| 94 |
-
value=0,
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 98 |
-
|
| 99 |
-
with gr.Row():
|
| 100 |
-
|
| 101 |
-
width = gr.Slider(
|
| 102 |
-
label="Width",
|
| 103 |
-
minimum=256,
|
| 104 |
-
maximum=MAX_IMAGE_SIZE,
|
| 105 |
-
step=32,
|
| 106 |
-
value=512,
|
| 107 |
-
)
|
| 108 |
-
|
| 109 |
-
height = gr.Slider(
|
| 110 |
-
label="Height",
|
| 111 |
-
minimum=256,
|
| 112 |
-
maximum=MAX_IMAGE_SIZE,
|
| 113 |
-
step=32,
|
| 114 |
-
value=512,
|
| 115 |
-
)
|
| 116 |
-
|
| 117 |
-
with gr.Row():
|
| 118 |
-
|
| 119 |
-
guidance_scale = gr.Slider(
|
| 120 |
-
label="Guidance scale",
|
| 121 |
-
minimum=0.0,
|
| 122 |
-
maximum=10.0,
|
| 123 |
-
step=0.1,
|
| 124 |
-
value=0.0,
|
| 125 |
-
)
|
| 126 |
-
|
| 127 |
-
num_inference_steps = gr.Slider(
|
| 128 |
-
label="Number of inference steps",
|
| 129 |
-
minimum=1,
|
| 130 |
-
maximum=12,
|
| 131 |
-
step=1,
|
| 132 |
-
value=2,
|
| 133 |
-
)
|
| 134 |
-
|
| 135 |
-
gr.Examples(
|
| 136 |
-
examples = examples,
|
| 137 |
-
inputs = [prompt]
|
| 138 |
-
)
|
| 139 |
-
|
| 140 |
-
run_button.click(
|
| 141 |
-
fn = infer,
|
| 142 |
-
inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
| 143 |
-
outputs = [result]
|
| 144 |
-
)
|
| 145 |
-
|
| 146 |
-
demo.queue().launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
from PIL import Image
|
| 4 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# Load your custom regression model
|
| 7 |
+
model_path = "pokemon_model_tl.keras"
|
| 8 |
+
model = tf.keras.models.load_model(model_path)
|
| 9 |
+
|
| 10 |
+
labels = ['Wartortle', 'Weedle', 'Weepinbell', 'Weezing']
|
| 11 |
+
|
| 12 |
+
# Define regression function
|
| 13 |
+
def predict_regression(image):
|
| 14 |
+
# Preprocess image
|
| 15 |
+
image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
|
| 16 |
+
image = image.resize((150, 150)).convert('RGB') #resize the image to 28x28 and converts it to gray scale
|
| 17 |
+
image = np.array(image)
|
| 18 |
+
print(image.shape)
|
| 19 |
+
# Predict
|
| 20 |
+
prediction = model.predict(image[None, ...]) # Assuming single regression value
|
| 21 |
+
confidences = {labels[i]: np.round(float(prediction[0][i]), 2) for i in range(len(labels))}
|
| 22 |
+
return confidences
|
| 23 |
+
|
| 24 |
+
# Create Gradio interface
|
| 25 |
+
input_image = gr.Image()
|
| 26 |
+
output_text = gr.Textbox(label="Predicted Value")
|
| 27 |
+
interface = gr.Interface(fn=predict_regression,
|
| 28 |
+
inputs=input_image,
|
| 29 |
+
outputs=gr.Label(),
|
| 30 |
+
examples=["wartortle.jpg", "weedle.jpg", "weepinbell.jpg", "weezing.jpg"],
|
| 31 |
+
description="A simple mlp classification model for image classification using the pokemon dataset.")
|
| 32 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|