adding interpolated location sampling

This commit is contained in:
terrance committed 2023-02-08 01:13:56 +00:00
1 parent 77634b97cf
commit 9a7209cd13
1 file changed
+28 -11
+28 -11
View File
@@ -37,11 +37,13 @@ class DreamfusionPipelineConfig(VanillaPipelineConfig):
"""target class to instantiate""" """target class to instantiate"""
datamanager: DreamFusionDataManagerConfig = DreamFusionDataManagerConfig() datamanager: DreamFusionDataManagerConfig = DreamFusionDataManagerConfig()
"""specifies the datamanager config""" """specifies the datamanager config"""
prompt: str = "A high quality photo of a pineapple" prompt: str = "A zoomed out high-quality photo of Temple of Heaven"
"""prompt for stable dreamfusion""" """prompt for stable dreamfusion"""
location_based_prompting: bool = True location_based_prompting: bool = True
"""enables location based prompting""" """enables location based prompting"""
interpolated_prompting: bool = False
"""enables interpolated location prompting"""
top_prompt: str = ", overhead view" top_prompt: str = ", overhead view"
"""appended to prompt for overhead view""" """appended to prompt for overhead view"""
side_prompt: str = ", side view" side_prompt: str = ", side view"
@@ -111,16 +113,31 @@ class DreamfusionPipeline(VanillaPipeline):
) )
if self.config.location_based_prompting: if self.config.location_based_prompting:
if batch["vertical"] < 30: if self.config.interpolated_prompting:
text_embedding = self.top_text_embedding horiz = batch["central"]
elif batch["central"] > 315 or batch["central"] <= 45: vert = batch["vertical"]
text_embedding = self.front_text_embedding
elif batch["central"] > 45 and batch["central"] <= 135: if batch["central"] > 315 or batch["central"] <= 45:
text_embedding = self.side_text_embedding text_embedding = self.front_text_embedding
elif batch["central"] > 135 and batch["central"] <= 225: elif batch["central"] > 45 and batch["central"] <= 135:
text_embedding = self.back_text_embedding text_embedding = self.side_text_embedding
else: # batch["central"] > 225 and batch["central"] <= 315: elif batch["central"] > 135 and batch["central"] <= 225:
text_embedding = self.side_text_embedding text_embedding = self.back_text_embedding
else: # batch["central"] > 225 and batch["central"] <= 315:
text_embedding = self.side_text_embedding
else:
if batch["vertical"] < 30:
text_embedding = self.top_text_embedding
elif batch["central"] > 315 or batch["central"] <= 45:
text_embedding = self.front_text_embedding
elif batch["central"] > 45 and batch["central"] <= 135:
text_embedding = self.side_text_embedding
elif batch["central"] > 135 and batch["central"] <= 225:
text_embedding = self.back_text_embedding
else: # batch["central"] > 225 and batch["central"] <= 315:
text_embedding = self.side_text_embedding
else: else:
text_embedding = self.base_text_embedding text_embedding = self.base_text_embedding