update replicate, remove unused examples
1
.gitignore
vendored
|
@ -16,3 +16,4 @@ dist
|
|||
build
|
||||
README
|
||||
.cog
|
||||
cog
|
||||
|
|
BIN
examples/artificial_intelligence.jpg
vendored
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 23 KiB |
BIN
examples/funeral.jpg
vendored
Before Width: | Height: | Size: 414 KiB |
BIN
examples/godzilla_trial.jpg
vendored
Before Width: | Height: | Size: 320 KiB |
BIN
examples/gollum_trailcam.jpg
vendored
Before Width: | Height: | Size: 190 KiB |
BIN
examples/ironman.jpg
vendored
Before Width: | Height: | Size: 504 KiB |
BIN
examples/jesus.jpg
vendored
Before Width: | Height: | Size: 206 KiB |
BIN
examples/panda_tophat_high_temp.jpg
vendored
Normal file
After Width: | Height: | Size: 294 KiB |
BIN
examples/panda_tophat_low_temp.jpg
vendored
Normal file
After Width: | Height: | Size: 214 KiB |
BIN
examples/yoda.jpg
vendored
Before Width: | Height: | Size: 250 KiB |
4
min_dalle.ipynb
vendored
|
@ -192,12 +192,12 @@
|
|||
"%%time\n",
|
||||
"\n",
|
||||
"text = \"Dali painting of WALL·E\" #@param {type:\"string\"}\n",
|
||||
"intermediate_outputs = True #@param {type:\"boolean\"}\n",
|
||||
"progressive_outputs = True #@param {type:\"boolean\"}\n",
|
||||
"grid_size = 5 #@param {type:\"integer\"}\n",
|
||||
"temperature = 2 #@param {type:\"slider\", min:0.01, max:3, step:0.01}\n",
|
||||
"supercondition_factor = 16 #@param {type:\"number\"}\n",
|
||||
"top_k = 256 #@param {type:\"integer\"}\n",
|
||||
"log2_mid_count = 3 if intermediate_outputs else 0\n",
|
||||
"log2_mid_count = 3 if progressive_outputs else 0\n",
|
||||
"\n",
|
||||
"image_stream = model.generate_image_stream(\n",
|
||||
" text=text,\n",
|
||||
|
|
|
@ -6,7 +6,6 @@ from cog import BasePredictor, Path, Input
|
|||
|
||||
torch.backends.cudnn.deterministic = False
|
||||
|
||||
|
||||
class ReplicatePredictor(BasePredictor):
|
||||
def setup(self):
|
||||
self.model = MinDalle(
|
||||
|
@ -18,22 +17,37 @@ class ReplicatePredictor(BasePredictor):
|
|||
def predict(
|
||||
self,
|
||||
text: str = Input(default='Dali painting of WALL·E'),
|
||||
output_png: bool = Input(default=False),
|
||||
intermediate_outputs: bool = Input(default=True),
|
||||
save_as_png: bool = Input(default=False),
|
||||
progressive_outputs: bool = Input(default=True),
|
||||
grid_size: int = Input(ge=1, le=9, default=5),
|
||||
log2_temperature: float = Input(ge=-3, le=3, default=2),
|
||||
log2_top_k: int = Input(ge=0, le=14, default=4),
|
||||
log2_supercondition_factor: float = Input(ge=2, le=6, default=4)
|
||||
temperature: str = Input(
|
||||
choices=(
|
||||
['1/{}'.format(2 ** i) for i in range(4, 0, -1)] +
|
||||
[str(2 ** i) for i in range(5)]
|
||||
),
|
||||
default='4',
|
||||
description='Advanced Setting, see Readme below if interested.'
|
||||
),
|
||||
top_k: int = Input(
|
||||
choices=[2 ** i for i in range(15)],
|
||||
default=64,
|
||||
description='Advanced Setting, see Readme below if interested.'
|
||||
),
|
||||
supercondition_factor: int = Input(
|
||||
choices=[2 ** i for i in range(2, 7)],
|
||||
default=16,
|
||||
description='Advanced Setting, see Readme below if interested.'
|
||||
)
|
||||
) -> Iterator[Path]:
|
||||
log2_mid_count = 3 if intermediate_outputs else 0
|
||||
log2_mid_count = 3 if progressive_outputs else 0
|
||||
image_stream = self.model.generate_image_stream(
|
||||
text = text,
|
||||
seed = -1,
|
||||
grid_size = grid_size,
|
||||
log2_mid_count = log2_mid_count,
|
||||
temperature = 2 ** log2_temperature,
|
||||
supercondition_factor = 2 ** log2_supercondition_factor,
|
||||
top_k = 2 ** log2_top_k,
|
||||
temperature = eval(temperature),
|
||||
supercondition_factor = float(supercondition_factor),
|
||||
top_k = top_k,
|
||||
is_verbose = True
|
||||
)
|
||||
|
||||
|
@ -41,7 +55,7 @@ class ReplicatePredictor(BasePredictor):
|
|||
path = Path(tempfile.mkdtemp())
|
||||
for image in image_stream:
|
||||
i += 1
|
||||
ext = 'png' if i == 2 ** log2_mid_count and output_png else 'jpg'
|
||||
ext = 'png' if i == 2 ** log2_mid_count and save_as_png else 'jpg'
|
||||
image_path = path / 'min-dalle-iter-{}.{}'.format(i, ext)
|
||||
image.save(str(image_path))
|
||||
yield image_path
|